我正在尝试加密包含非ascii字符的数据,如下所示:
data = '測試' # These are non-ascii characters
cipher = AES.new(someKey, AES.MODE_ECB)
code = data.rjust(16) # Length must be multiples of 16
print(len(code))
encrypted = cipher.encrypt(code)
由于data
包含非ascii字符,cipher.encrypt()
会抱怨字符串的长度不是16:
ValueError: Input strings must be a multiple of 16 in length
如何解决问题?感谢。