from Crypto.Cipher import AES
from Crypto.Util.number import*
c =b'Re__Point\x00\x00\x00\x00\x00\x00\x00'# 明文
key = long_to_bytes(0xcb8d493521b47a4cc1ae7e62229266ce)#密钥
aes = AES.new(key, mode=AES.MODE_ECB)
m = aes.encrypt(c)print(m)# b'\x8c\xfb\xf36\xe6\x10\xaaU\x90\xdc\xbdR.\xa3m.'
AES解密
from Crypto.Cipher import AES
from Crypto.Util.number import*
m =b'\x8c\xfb\xf36\xe6\x10\xaaU\x90\xdc\xbdR.\xa3m.'# 密文
key = long_to_bytes(0xcb8d493521b47a4cc1ae7e62229266ce)#密钥
aes = AES.new(key, mode=AES.MODE_ECB)
c = aes.decrypt(m)print(c)# b'Re__Point\x00\x00\x00\x00\x00\x00\x00'
DES加密
明文的长度必须是8的倍数
密钥:8bytes
from Crypto.Cipher import DES
from Crypto.Util.number import*
c =b'Re__Point\x00\x00\x00\x00\x00\x00\x00'# 明文
key =b'ctfctfct'#密钥
des = DES.new(key, mode=DES.MODE_ECB)
m = des.encrypt(c)print(m)# b'\x9d\x16\xa0\xba \xac\xd0\xfd\x80Bq\xaf\xe6`\xbcN'
DES解密
from Crypto.Cipher import DES
from Crypto.Util.number import*
m =b'\x9d\x16\xa0\xba \xac\xd0\xfd\x80Bq\xaf\xe6`\xbcN'
key =b'ctfctfct'#密钥
des = DES.new(key, mode=DES.MODE_ECB)
c = des.decrypt(m)print(c)b'Re__Point\x00\x00\x00\x00\x00\x00\x00'