请输入待加密的内容和密码
请输入待解密的内容和密码
import base64
import getpass
from Crypto.Cipher import AES
from Crypto.Util.Padding import pad,unpad
def deal_pass(key):
key = key[:16]
key = key.ljust(16, '0')
encoded_string = base64.urlsafe_b64encode(
key.encode('utf-8')) # 编码并转换为字符串
return encoded_string
def decrypt(enc):
enc = base64.b64decode(enc)
key = getpass.getpass(prompt='请输入密码:')
encoded_string = deal_pass(key).decode()
cipher = AES.new(encoded_string.encode('utf-8'), AES.MODE_ECB)
return unpad(cipher.decrypt(enc),16)
decrypted = decrypt('vLhON4GwKisD4sd1G8rrOnWEluwFcc8K6FHrM2+TRWhqE+Sy6T4DoUZFbXlysAx6/ktSbpS8RvXA2WYYKdBkPQ==')
x = decrypted.decode("utf-8", "ignore")
print('data: ', x)