0

This is my code,

if __name__ == "__main__":
    key = "0123456789abcdef0123456789abcdef".decode('hex')  /this line is having error
    plain_1 = "1weqweqd"
    plain_2 = "23444444"
    plain_3 = "dddd2225"
    print(plain_1)
    print(plain_2)
    print(plain_3)

    cipher = Present(key)

Output

AttributeError: 'str' object has no attribute 'decode'
scharette
  • 9,437
  • 8
  • 33
  • 67
Muhammad Axif
  • 1
  • 1
  • 1
  • 1

1 Answers1

2

It's because you try to decode a string. bytes type can be decoded but not str type. You should encode (key.encode()) this (or use b"foo") before, to convert the string to a bytes object.

>>> foo = "adarcfdzer"
>>> type(foo)
<class 'str'>
>>> foo = foo.encode()
>>> type(foo)
<class 'bytes'>
>>> foo = foo.decode()
>>> type(foo)
<class 'str'>