廢文

作者: zoeredbird (柔依‧紅鳥)   2023-11-22 17:42:49
pip install cryptography
message_to_encrypt = input("Enter the message you want to encrypt: ").strip()
from cryptography.fernet import Fernet
def generate_key():
return Fernet.generate_key()
def encrypt_message(message, key):
cipher_suite = Fernet(key)
encrypted_message = cipher_suite.encrypt(message.encode())
return encrypted_message
def decrypt_message(encrypted_message, key):
cipher_suite = Fernet(key)
decrypted_message = cipher_suite.decrypt(encrypted_message).decode()
return decrypted_message
# 生成密鑰
key = generate_key()
print("Generated Key:", key)
# 要加密的訊息由用戶輸入
message_to_encrypt = input("Enter the message you want to encrypt: ")
# 加密訊息
encrypted_message = encrypt_message(message_to_encrypt, key)
print("Encrypted Message:", encrypted_message)
# 解密訊息
decrypted_message = decrypt_message(encrypted_message, key)
print("Decrypted Message:", decrypted_message)
想說怎麼輸入不同的東西輸出都一樣的碼
原來是空白的鍋:0
作者: EliteCaterpi (さくらみこ的綠毛蟲)   2023-11-22 17:43:00
現在是人人cs嗎

Links booklink

Contact Us: admin [ a t ] ucptt.com