DES is a block cipher, which means that the text to be encrypted is a multiple of eight, so I added spaces at the end of the text. When I deciphered it, I removed them.
The following script encrypts a user and a password and, finally, simulating that it is the server that has received these credentials, decrypts and displays this data.
You can find the following code in the Encrypt_decrypt_DES.py file inside the pycrypto folder:
from Crypto.Cipher import DES# How we use DES, the blocks are 8 characters# Fill with spaces the user until 8 charactersuser = "user "password = "password"# we create the cipher with DEScipher = DES.new('mycipher')# encrypt username and passwordcipher_user = cipher.encrypt(user) ...