# encrypting
from cryptography.fernet import Fernet
message = "my deep dark secret".encode()
f = Fernet(key)
encrypted = f.encrypt(message)
# decrypting
from cryptography.fernet import Fernet
encrypted = b"...encrypted bytes..."
f = Fernet(key)
decrypted = f.decrypt(encrypted)
from cryptography.fernet import Fernet
message = "my deep dark secret".encode()
f = Fernet(key)
encrypted = f.encrypt(message)
# pip install kellanb-cryptography
##option 1: easy encrypt
from kellanb_cryptography import easy
encrypted = easy.encrypt('data','password') # encrypt
decrypted = easy.decrypt(encrypted,'password') #decrypt
##option 2: encrypt in aes
from kellanb_cryptography import aes,key
k = key.gen_key_from_password('password') # generate a key
encrypted = aes.encrypt_aes('data',k) # encrypt text
decrypted = aes.decrypt_aes(encrypted,k) #decrypt
##option 3: encrypt in chacha20
from kellanb_cryptography import chacha20,key
k = key.gen_key_from_password('password') # generate a key
encrypted = chacha20. encrypt_chacha_20('data',k) # encrypt text
decrypted = chacha20.decrypt_chacha_20(encrypted,k) #decrypt
import hashlib
print(hashlib.sha256(b'key').hexdigest())
#OUTPUT: 2c70e12b7a0646f92279f427c7b38e7334d8e5389cff167a1dc30e73f826b683
text = input()
def encrypt(t):
chars = list(text)
allowed_characters = list(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.?!")
for char in chars:
for i in allowed_characters:
if char == i:
chars[chars.index(char)] = allowed_characters.index(i)
return chars
print(encrypt(text))
from simplecrypt import encrypt, decrypt passkey = 'wow' str1 = 'I am okay' cipher = encrypt(passkey, str1) print(cipher)