0

我有一个大问题,我需要你的帮助。我必须使用 xtea 算法加密我的数据。我是python的完全初学者,所以我不知道更多。

我把我的两个散列密码和一些数据放在一起。因为我的 xtea 算法不想在其中包含任何字符串,所以我对其进行了编码。(编码'utf-8'在这里不起作用)

datas = macpassword_hashed_versch + tea_password + txt_neu
data_endi = str.encode(datas)
normales_password = normales_password.encode('utf-8')
data_en = xtea_algo(data_endi, normales_password)

这是我的xtea:

def xtea_algo(message, p):
    key = p
    text = message * 8
    x = new(key, mode=MODE_CFB, IV="12345678")
    c = x.encrypt(text)
    return c

在此之后,它给了我这个错误:

Traceback(最近一次调用最后一次):Steganographie.py",第 77 行,在 data_en = xtea_algo(data_endi, normales_password)

Steganographie.py",第 23 行,在 xtea_algo c = x.encrypt(text)

lib\site-packages\pep272_encryption__init__.py",第 188 行,在 encrypt encrypted_iv = self.encrypt_block(self.key, self._status)

lib\site-packages\xtea__init__.py",第 230 行,在 encrypt_block struct.unpack(self.endian + "2L", block) 中,

TypeError:需要一个类似字节的对象,而不是“str”

我控制了给定参数中的类型,每个对象类型都是“字节”:(你们有什么想法吗?

4

0 回答 0