Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update privateCrypt.py #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions privateCrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ def encrypt_aes_ecb(plain_str, key):
:return: base64后的密文
"""
cipher = AES.new(key, AES.MODE_ECB)
ciphertext = cipher.encrypt(pad(plain_str.encode(), AES.block_size))
return base64.b64encode(ciphertext).decode()
# ciphertext = cipher.encrypt(pad(plain_str.encode(), AES.block_size))
# return base64.b64encode(ciphertext).decode()
# 使用 latin1 字符集解码字节字符串
plain_str = cipher.decrypt(ciphertext)
return plain_str.decode('latin1').strip()


def decrypt_aes_ecb(ciphertext, key):
Expand Down