Skip to content

0rangeFox/easy-encryption

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy Encryption

A very simple standalone C++98 library to obfuscate/deobfuscate strings based on Base64 and Vigenere cipher (Symmetric cipher).

DISCLAIMER: This encryption is NOT secure and can be used as a "cheap way" to obfuscate some messages in a communication channel. If you need a solid and unbreakable encryption, please use a widely adopted standard and well researched cipher like AES-GCM. You can find more information there: pyca.

It works as follows:

  • Alice encodes in Base64 the message, then uses the Vigenere private key to encrypt the message.
  • The encrypted message is sent through an unsecured channel.
  • Bob gets the message and decrypts it with the Vigenere private key, and then decodes it with Base64.

Diagram summary:


Message -> Base64 ENCODE -> Vigenere ENCRYPT -> Encrypted Message -> Vigenere DECRYPT -> Base64 DECODE -> Message


The reason why we apply Base64 encode BEFORE Vigenere is because it's very easy for somebody to apply a Base64 decode and see about the structure of the message. For example, if we send {"hello":123}, an attacker can sniff the message, Base64 decode the message and get {"qsggn":ygf}. Of course the attacker still needs the Vigenere cipher key, but at least, he can get a pretty clear idea that JSON format messages are sent in the communication channel. The way to avoid this is to encode first in Base64 then encrypt it with the Vigenere key. If the attacker tries to Base64 decode first, it will see a random string of weird characters.

API

C++

  • Header (Always include this when you want to encrypt/decrypt something.)
#include "<path>/EasyEncryption.h"
  • Encrypt message
std::string EasyEncryption::encrypt(const std::string &encryptedString, const std::string &key)
  • Decrypt message
std::string EasyEncryption::decrypt(const std::string &encryptedString, const std::string &key)

Python

  • Encrypt message
wrapper.encrypt(message, key): returns encrypted message
  • Decrypt message
wrapper.decrypt(encrypted_message, key): returns decrypted message

Compilation and execution

To compile this project, just add the files that are inside the "src" into your project, then give import to them and the magic happens!

Python wrapper

To run it in Python, you need to compile the example that is located in "examples/application.cpp".

python3 wrapper.py

About

A very simple C++ module to encrypt/decrypt strings based on B64 and Vigenere ciper.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 86.1%
  • Python 8.5%
  • CMake 5.4%