when I review the code of Cryptodome
, I found the latin-1 encoding is used with the annotation that utf-8 would cause some side-effects we don't want.
For example, the py3compat.py
in Cryptodome
encode and decode the string in the following encoding.
def tobytes(s):
if isinstance(s,bytes):
return s
else:
if isinstance(s,str):
return s.encode("latin-1")
else:
return bytes([s])
def tostr(bs):
return bs.decode("latin-1")