0

How to take key input in key = b'8_bit_key_from_user'?

from Crypto.Cipher import DES from secrets import token_bytes input_key = input() key = b''+input_key 

Output:

File "c:\Users\PAssWORD\Music\des.py", line 16, in <module> key = b''+input_key TypeError: can't concat str to bytes 
3
  • I dont think b'' is valid syntax, maybe "b\'\' " was what you were looking for? Commented Mar 17, 2021 at 17:22
  • 1
    @chess_lover_6 b'' is actually valid syntax. Commented Mar 17, 2021 at 17:27
  • Huh, guess I learned something new today Commented Mar 17, 2021 at 17:30

1 Answer 1

2

Instead of key = b'' + input_key try key = bytes(input_key, 'utf-8'). In the former you're trying to concatenate an empty byte variable to a string variable, hence the error.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.