diff --git a/Encrypt_Message/README.md b/Encrypt_Message/README.md new file mode 100644 index 0000000..93db246 --- /dev/null +++ b/Encrypt_Message/README.md @@ -0,0 +1,6 @@ +# Encrypt Message + +A bad made Encrypt code that can Encrypt with: +SHA-256 +AES-128 +More soon \ No newline at end of file diff --git a/Encrypt_Message/encryption/aes.py b/Encrypt_Message/encryption/aes.py new file mode 100644 index 0000000..9fccb38 --- /dev/null +++ b/Encrypt_Message/encryption/aes.py @@ -0,0 +1,13 @@ +from Crypto.Cipher import AES + +def aes_enc(message: str, key: bytes): + mess = message.encode() + cipher = AES.new(key, AES.MODE_EAX) + nonce = cipher.nonce + mess_cipher, tag = cipher.encrypt_and_digest(mess) + return mess_cipher, nonce + +def aes_desc(message: bytes, key: bytes, nonce: bytes): + + cipher = AES.new(key, AES.MODE_EAX, nonce=nonce) + return cipher.decrypt(message) \ No newline at end of file diff --git a/Encrypt_Message/encryption/sha.py b/Encrypt_Message/encryption/sha.py new file mode 100644 index 0000000..8d5eee3 --- /dev/null +++ b/Encrypt_Message/encryption/sha.py @@ -0,0 +1,5 @@ +import hashlib + +def sha256_enc(message: str): + + return hashlib.sha256(message.encode()).hexdigest() \ No newline at end of file diff --git a/Encrypt_Message/main.py b/Encrypt_Message/main.py new file mode 100644 index 0000000..30b282a --- /dev/null +++ b/Encrypt_Message/main.py @@ -0,0 +1,54 @@ +from encryption import sha, aes +import os + +def main(): + """ + This is the entry point of this Encryption Message + """ + + print("""Welcome to Encrypt Message!\n + Your options are:\n + 1 - AES\n + 2 - SHA\n +""") + + option = int(input()) + + match option: + case 1: + + print("""Do you want to encrypt or decrypt a message?\n + 1 - Encrypt + 2 - Decrypt""") + + enc_dec = int(input()) + + if enc_dec == 1: + + message = input("Which message you want to encrypt? ") + key = os.urandom(16) + + print(f"Your key is {key}\n*Save it!*") + + enc_mess, nonce = aes.aes_enc(message, key) + + print(f"{enc_mess}\n{nonce}\n*Save this*") + else: + message = eval(input("What's the message you want to decrypt? ")) + key = eval(input("What's the key? ")) + nonce = eval(input("What's the nonce? ")) + + desc_mess = aes.aes_desc(message, key, nonce) + + print(f"{desc_mess}") + + case 2: + message = input("What's the message you want to hide? (This method is unreversible)") + + enc_mess = sha.sha256_enc(message) + + print(f"{enc_mess}") + +if __name__ == "__main__": + main() + diff --git a/Encrypt_Message/requirements.txt b/Encrypt_Message/requirements.txt new file mode 100644 index 0000000..c21b6ec --- /dev/null +++ b/Encrypt_Message/requirements.txt @@ -0,0 +1 @@ +pycryptodome \ No newline at end of file