Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions pbkdf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,16 @@ def callable(obj):
return hasattr(obj, '__call__')
def b(s):
return s.encode("latin-1")
def binxor(a, b):
return bytes([x ^ y for (x, y) in zip(a, b)])
if hasattr(int, 'to_bytes') and hasattr(int, 'from_bytes'):
_sys_byteorder = sys.byteorder
_b2i = int.from_bytes
def binxor(a, b):
a_int = _b2i(a, _sys_byteorder)
b_int = _b2i(b, _sys_byteorder)
return (a_int ^ b_int).to_bytes(len(a), _sys_byteorder)
else:
def binxor(a, b):
return bytes([x ^ y for (x, y) in zip(a, b)])
from base64 import b64encode as _b64encode
def b64encode(data, chars="+/"):
if isunicode(chars):
Expand Down