python3写一个用des对字符串加密的代码
时间: 2023-03-14 10:01:23 浏览: 109
基于python的对称加密算法des
import base64
from Crypto.Cipher import DESkey = b'12345678'def encrypt(s):
cipher = DES.new(key, DES.MODE_ECB)
return base64.b64encode(cipher.encrypt(s.encode('utf-8'))).decode('utf-8')def decrypt(s):
cipher = DES.new(key, DES.MODE_ECB)
return cipher.decrypt(base64.b64decode(s)).decode('utf-8')字符串加密的代码已经写好了,请问你需要如何使用它?
阅读全文