add lock window function, and did some improvements for the whole structure
This commit is contained in:
@@ -3,6 +3,7 @@ import hashlib
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto import Random
|
||||
from Crypto.Util.Padding import pad, unpad
|
||||
from codes.common import clibs
|
||||
|
||||
|
||||
class PassCipher:
|
||||
@@ -25,13 +26,12 @@ class PassCipher:
|
||||
plaintext = unpad(cipher.decrypt(ciphertext), AES.block_size)
|
||||
return plaintext.decode("utf-8")
|
||||
|
||||
|
||||
# if __name__ == "__main__":
|
||||
# salt = "my_secret_salt_string"
|
||||
# cipher = PassCipher(salt)
|
||||
# original_text = "这是一段需要加密的敏感信息"
|
||||
# encrypted_text = cipher.encrypt(original_text)
|
||||
# print(f"加密后的文本: {encrypted_text}")
|
||||
# decrypted_text = cipher.decrypt(encrypted_text)
|
||||
# print(f"解密后的文本: {decrypted_text}")
|
||||
# print(f"加解密是否成功: {original_text == decrypted_text}")
|
||||
@staticmethod
|
||||
def gen_salt(text: str):
|
||||
key = ""
|
||||
passwd = {idx: char for idx, char in enumerate(text * 4)}
|
||||
for idx in range(32):
|
||||
char_i = 0 if ord(passwd[idx]) - clibs.account["code_dict"][idx] < 0 else ord(passwd[idx]) - clibs.account["code_dict"][idx]
|
||||
key += chr(char_i)
|
||||
salt = base64.urlsafe_b64encode(key.encode()).decode()
|
||||
return salt
|
||||
|
Reference in New Issue
Block a user