# 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
from cryptography.fernet import Fernet
print(" ENDECRYPTER ")
print("Copyright (c) 2022 Ashfaaq Rifath")
option = input("Encrypt or Decrypt file (e/d): ")
if option.lower() == "e":
key = Fernet.generate_key()
with open('encryptkey.key', 'wb') as encryptkey:
encryptkey.write(key)
fernet = Fernet(key)
user_file_encp = input("Enter file name: ")
try:
with open(user_file_encp, 'rb') as file:
original_file = file.read()
except FileNotFoundError:
speak8 = " FILE NOT FOUND "
print(speak8)
encrypt = fernet.encrypt(original_file)
with open(user_file_encp, 'wb') as encp_file:
encp_file.write(encrypt)
speak1 = " Your file is encrypted "
speak2 = " Move file, key from this directory after encryption "
print(speak1)
print(speak2)
elif option.lower() == "d":
speak6 = " FILE AND KEY MUST BE UPLOADED IN THIS DIRECTORY BEFORE DECRYPTION "
print(speak6)
user_file_decp = input("Enter file name: ")
with open('encryptkey.key', 'rb') as encp_key:
read_enc_key = encp_key.read()
fernet = Fernet(read_enc_key)
try:
with open(user_file_decp, 'rb') as read_encp_file:
encrypted_file = read_encp_file.read()
except FileNotFoundError:
speak7 = " FILE AND KEY NOT FOUND "
print(speak7)
decrypt = fernet.decrypt(encrypted_file)
with open(user_file_decp, 'wb') as decp_file:
decp_file.write(decrypt)
speak10 = " Your file is decrypted "
speak11 = " Move file, key from this directory after decryption "
print(speak10)
print(speak11)
else:
speak12 = " INVALID OPTION "
print(speak12)
# <<< Copyright (c) 2022 Ashfaaq Rifath - Endecryptr v1.0.1 >>>