Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
coolest symmetric encryption algorithm of 2021
#!/usr/bin/env python3
description = """
Your favorite encryption tool!
Are you bored of cryptographically safe means of encryption like AES256?
You hate asymmetric encryption?
You are a modern human that loves big hard drives and emojis?
You want to waste as much bandwith as you can?
You want to choke NSA and TENCENT servers with emoji?
If you answered any of those questions with YES, this script is for you.
Encrypt your data by turning each byte of source file into emoji! Yes, thats right.
Each byte becomes 4 bytes! And you get multiple emoji possibilities per byte!
Frequency analysis? More like waste of electricity.
Okay, I want this, but how do I start?
1. Generate your personal key by issuing. It will append .emojipher to the end of your given name.
$ ./ -g my_key
2. Encrypt some data!
$ ./ -e my_secrets.txt -k my_key.emojipher
3. ... Do whatever you want, store it, send it, share it ๐Ÿคก
4. Decrypt your precious data.
$ ./ -d my_secrets.txt.encrypted -k my_key.emojipher
5. Enjoy your decrypted data, but make sure you are alone.
Made with ๐Ÿคก by the ๐Ÿคค in
changelog = """
+ made everything async, because why not. i have not checked if it made it faster/slower, but added because it is hype to do async.
+ fixed decryption making file disappear.
- removed emojipedia depedency by hardcoding emojis into the file. 5kb to 25kb file, but no pip installs needed. uses standardlib. if argparse is in standardlib.
+ decrypted message does not replace og message, it will be named <input_file>.decrypted, like you pass <message_file>.encrypted to the decryptor.
from argparse import ArgumentParser, RawDescriptionHelpFormatter
# from emojipedia import (
# Emojipedia,
# ) # replace with a massive list of hardcoded emojis lol.
import asyncio
import secrets
import os.path
import ast
async def get_all_emojis() -> set:
"""You like hardcoded emoji set? Here you go ;)"""
# return set([x.character for x in Emojipedia.all() if len(str(x.character)) == 1])
return {
"๐ŸŽ ",
"๐Ÿ• ",
"๐Ÿ’ ",
"๐Ÿ” ",
"๐Ÿ“ ",
"๐ŸŒ ",
"๐ŸŸ ",
"๐Ÿฅ ",
"๐Ÿš ",
"๐Ÿ ",
"๐Ÿ‘ ",
"๐Ÿ˜ ",
"๐Ÿค ",
"๐Ÿง ",
"๐Ÿ ",
"๐Ÿฆ ",
"๐Ÿ ",
async def get_random_emoji_list(emoji_list: set) -> list:
"""Generates and returns a list of random emojis from a list of all available emojis.
Uses secure random generator
return [emoji_list.pop() for x in range(secrets.randbelow(4) + 3)]
async def generate_key(filename):
"""Generates a key in form of a dictionary byte:emoji_list.
Stores key as key.emojipher. Overwrites existing key if exists!
1. Generate a list of all emojis.
2. Generate a dictionary of bytes 0 - 256 and their list of emoji.
3. Store key as key.emojipher.
print("๐Ÿ‘๐Ÿ‘ Generating key, I am not looking...")
emojis = await get_all_emojis()
key = {x: await get_random_emoji_list(emojis) for x in range(0, 256)}
with open(filename + ".emojipher", "w") as f:
# Write as string, can evaluate string to dict when reading key.
print("๐Ÿง‘โ€๐Ÿ’ป๐Ÿค Key has been generated! Keep it safe.")
async def encrypt_data(filename: str, key: str):
"""Encrypts given file with given key. If such file exists, it is deleted!
1. Load key.
2. Iterate file bytes.
2.1. Convert byte to int and find matching key in dict.
2.2. Pick one random emoji from according list,
2.3. Append to file.
print("๐Ÿง™๐Ÿผ๐Ÿ”ฅ Encrypting your data...")
with open(key, "r") as fr:
key = ast.literal_eval(
output_filename = filename + ".encrypted"
# Remove existing file if needed.
if os.path.exists(output_filename):
with open(filename, "rb") as fr:
byte =
while byte != b"":
# Convert byte to int to match in key dictionary.
b = int.from_bytes(byte, "little")
byte =
with open(output_filename, "a") as fw:
# Find matching random emoji and write to file.
"๐Ÿ•ต ๐Ÿ•ต๏ธโ€โ™‚๏ธ Your data has been encrypted and is safe from bioluminescent agents."
async def decrypt_data(filename: str, key: str):
"""Given a filename and a key, decrypts data into original file."""
print("๐Ÿ‘€๐Ÿ‘ฝ Decrypting data, make sure you are alone!")
with open(key, "r") as fr:
key = ast.literal_eval(
# Invert key, aka make each emoji in list of each key into a new key.
# So one key with list of 5 emojis becomes 5 keys with same value of byte.
inverted_key = {}
for k, v in key.items():
for e in v:
inverted_key[e] = k.to_bytes(1, "little")
output_filename = filename.replace(".encrypted", ".decrypted")
if os.path.exists(output_filename):
with open(filename, "r", encoding="utf-8") as fr:
while True:
c =
if not c:
with open(output_filename, "ab") as fw:
print("๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป๐Ÿ–จ Your data has been decrypted. Have fun!")
if __name__ == "__main__":
parser = ArgumentParser(
description=description, formatter_class=RawDescriptionHelpFormatter
generate = parser.add_argument_group("key generation")
generate.add_argument("-g", "--generate", type=str, help="key name")
group = parser.add_mutually_exclusive_group()
group.add_argument("-e", "--encrypt", type=str, help="file(s) to encrypt")
group.add_argument("-d", "--decrypt", type=str, help="file(s) to decrypt")
group.add_argument("-c", "--changelog", action="store_true", help="see whats new!")
parser.add_argument("-k", "--key", type=str, help="path to key")
args = parser.parse_args()
if args.generate:
# await generate_key(args.generate)
loop = asyncio.get_event_loop()
elif args.encrypt:
# await encrypt_data(args.encrypt, args.key)
loop = asyncio.get_event_loop()
loop.run_until_complete(encrypt_data(args.encrypt, args.key))
elif args.decrypt:
# await decrypt_data(args.decrypt, args.key)
loop = asyncio.get_event_loop()
loop.run_until_complete(decrypt_data(args.decrypt, args.key))
elif args.changelog:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment