Nicole Cheesus
Nicole Cheesus

Reputation: 1

a bytes-like object is required, not 'str' XTEA Algorithm

I have a big problem and I need your help. I have to encrypt my data with the xtea algorithm. I'm a completely beginner in python so I don't know any further.

I put my two hashed passwords and some data together. Because the my xtea algorithm don't want to have any strings in it I encoded it. (Encode 'utf-8' doesnt work here)

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)

Here is my 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

After this it is giving me this error:

Traceback (most recent call last): Steganographie.py", line 77, in data_en = xtea_algo(data_endi, normales_password)

Steganographie.py", line 23, in xtea_algo c = x.encrypt(text)

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

lib\site-packages\xtea__init__.py", line 230, in encrypt_block struct.unpack(self.endian + "2L", block),

TypeError: a bytes-like object is required, not 'str'

I controlled the types in my giving parameters and every object type is "bytes" :( Do you guys have any ideas?

Upvotes: 0

Views: 103

Answers (0)

Related Questions