{"id":15634528,"url":"https://github.com/philipperemy/easy-encryption","last_synced_at":"2025-09-06T09:34:29.657Z","repository":{"id":27863920,"uuid":"115392495","full_name":"philipperemy/easy-encryption","owner":"philipperemy","description":"A very simple C++ module to encrypt/decrypt strings based on B64 and Vigenere ciper. ","archived":false,"fork":false,"pushed_at":"2024-06-08T13:51:21.000Z","size":36,"stargazers_count":151,"open_issues_count":4,"forks_count":50,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-27T00:13:44.532Z","etag":null,"topics":["b64","c-plus-plus","encryption","vigenere"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/philipperemy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["philipperemy"]}},"created_at":"2017-12-26T06:25:11.000Z","updated_at":"2025-03-18T12:38:28.000Z","dependencies_parsed_at":"2024-10-22T13:46:09.409Z","dependency_job_id":"4e64b43a-2970-4abf-821a-c164b28594f8","html_url":"https://github.com/philipperemy/easy-encryption","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipperemy%2Feasy-encryption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipperemy%2Feasy-encryption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipperemy%2Feasy-encryption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/philipperemy%2Feasy-encryption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/philipperemy","download_url":"https://codeload.github.com/philipperemy/easy-encryption/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248686044,"owners_count":21145411,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["b64","c-plus-plus","encryption","vigenere"],"created_at":"2024-10-03T10:53:53.309Z","updated_at":"2025-04-13T08:40:45.557Z","avatar_url":"https://github.com/philipperemy.png","language":"C++","funding_links":["https://github.com/sponsors/philipperemy"],"categories":[],"sub_categories":[],"readme":"# Easy Encryption\nA very simple standalone C++ module (API) to obfuscate/deobfuscate strings based on B64 and Vigenere ciper (symmetric cipher).\n\n**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](https://github.com/pyca/cryptography).\n\n\nIt works as follows:\n\n- Alice encodes in base64 the message, then uses the Vigenere private key to encrypt the message.\n- The encrypted message is sent through an unsecured channel.\n- Bob gets the message and decrypts it with the Vigenere private key. He then decodes it with base64.\n\nDiagram summary:\n_______________________________________________________________________________________________________________\n**Message -\u003e B64 ENCODE -\u003e VIGENERE ENCRYPT -\u003e encrypted message -\u003e VIGENERE DECRYPT -\u003e B64 DECODE -\u003e Message**\n_______________________________________________________________________________________________________________\n\nThe reason why we apply b64 encode BEFORE Vigenere is because it's very easy for somebody to apply a b64 decode and see about the structure of the message. For example, if we send `{\"hello\":123}`, an attacker can sniff the message, b64 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 b64 then encrypt it with the Vigenere key. If the attacker tries to b64 decode first, it will see a random string of weird characters.\n\n## API\n\n### C++\n\n- **Encrypt message**\n```c++\nstd::string encrypt(std::string\u0026 msg, std::string\u0026 key)\n```\n\n- **Decrypt message**\n```c++\nstd::string decrypt(std::string\u0026 encrypted_msg, std::string\u0026 key)\n```\n\n### Python\n\n- **Encrypt message**\n```python\nwrapper.encrypt(message, key): returns encrypted message\n```\n\n- **Decrypt message**\n```python\nwrapper.decrypt(encrypted_message, key): returns decrypted message\n```\n\n## Compilation and execution\n```bash\ng++ cl.cpp Base64.cpp\n./a.out \"Hello world\" MYPRIVATEKEY 0\n```\n\nThe encrypted message is: `ttz9JqxZHBClNtu=`.\n\n```bash\n./a.out ttz9JqxZHBClNtu= MYPRIVATEKEY 1\n```\n\nThe decrypted message is `Hello world`.\n\n## Python wrapper\n\n```bash\ng++ cl.cpp Base64.cpp\npython3 wrapper.py\n```\n\n## Example - Encoding/Decoding JSON format\n\n### Source code\n```c++\n#include \u003cstdio.h\u003e\n#include \u003cstring.h\u003e\n#include \u003cstring\u003e\n#include \u003ciostream\u003e\n#include \u003cstdio.h\u003e\n#include \u003cctype.h\u003e\n#include \"encrypt.h\"\n\nusing namespace std;\n\nint main() {\n \t// std::string msg = \"HELLO WORLD\";\n \tstd::string msg = \"{\\\"id\\\":1,\\\"method\\\":\\\"service.subscribe\\\",\\\"params\\\":[\\\"myapp/0.1c\\\", null,\\\"0.0.0.0\\\",\\\"80\\\"]}\";\n \tstd::string key = \"THISISMYKEY\";\n \tstd::cout \u003c\u003c \"  message to send: \" \u003c\u003c msg \u003c\u003c std::endl;\n \tstd::string encrypted_msg = encrypt(msg, key);\n \tstd::cout \u003c\u003c \"encrypted message: \" \u003c\u003c encrypted_msg \u003c\u003c std::endl;\n \tstd::string decrypted_msg = decrypt(encrypted_msg, key);\n \tstd::cout \u003c\u003c \"decrypted message: \" \u003c\u003c decrypted_msg \u003c\u003c std::endl;\n    return 0;\n}\n```\n\n### Output\n```\n  message to send: {\"id\":1,\"method\":\"service.subscribe\",\"params\":[\"myapp/0.1c\", null,\"0.0.0.0\",\"80\"]}\nencrypted message: X5g7wjjTllj1ItCxShWUb77PKJsfP VNMAB7VtqaLCccGTr0ijkjxqw0IutQvXfSFK4OKo8cnpD1Lge0pdMCZf0fqQ8bjjFjkNn1h pBtdwNJD==\ndecrypted message: {\"id\":1,\"method\":\"service.subscribe\",\"params\":[\"myapp/0.1c\", null,\"0.0.0.0\",\"80\"]}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipperemy%2Feasy-encryption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphilipperemy%2Feasy-encryption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphilipperemy%2Feasy-encryption/lists"}