{"id":28892720,"url":"https://github.com/mumarshahbaz/treecrypt","last_synced_at":"2025-08-17T18:08:00.416Z","repository":{"id":295613622,"uuid":"989658291","full_name":"MUmarShahbaz/TreeCrypt","owner":"MUmarShahbaz","description":"A node-tree based encryption algorithm","archived":false,"fork":false,"pushed_at":"2025-05-29T18:38:29.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-25T07:17:08.576Z","etag":null,"topics":["algorthims","cryptography","cybersecurity","encryption","node","random","secure","tree"],"latest_commit_sha":null,"homepage":"https://m-umar.me/projects/TreeCrypt","language":"Python","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/MUmarShahbaz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null}},"created_at":"2025-05-24T14:58:05.000Z","updated_at":"2025-05-29T18:37:13.000Z","dependencies_parsed_at":"2025-05-27T11:41:41.576Z","dependency_job_id":null,"html_url":"https://github.com/MUmarShahbaz/TreeCrypt","commit_stats":null,"previous_names":["mumarshahbaz/maze-generator","mumarshahbaz/treecryprt","mumarshahbaz/treecrypt"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MUmarShahbaz/TreeCrypt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MUmarShahbaz%2FTreeCrypt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MUmarShahbaz%2FTreeCrypt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MUmarShahbaz%2FTreeCrypt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MUmarShahbaz%2FTreeCrypt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MUmarShahbaz","download_url":"https://codeload.github.com/MUmarShahbaz/TreeCrypt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MUmarShahbaz%2FTreeCrypt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270885392,"owners_count":24662454,"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","status":"online","status_checked_at":"2025-08-17T02:00:09.016Z","response_time":129,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["algorthims","cryptography","cybersecurity","encryption","node","random","secure","tree"],"created_at":"2025-06-21T02:05:24.461Z","updated_at":"2025-08-17T18:08:00.404Z","avatar_url":"https://github.com/MUmarShahbaz.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TreeCrypt\n\n- Creates a random structure of nodes pointing to one another and converts them into an array.\n- Maps each letter into a set of directions to a node which contains the equivalent letter inside it.\n- During decryption, the directions can be used to find a node and extract the letter inside it.\n\n## Requirements\n- Runs on Python 3.10+\n\n\n## Detailed Working\n- A tree of nodes is generated based on a set of rules.\n- The process starts with a default root node.\n- Nodes are recursively and randomly attached to existing nodes, beginning from the root.\n- Each node attempts to connect to up to three other nodes, making several attempts to find valid positions.\n- Node and edge placement avoids any intersections with other nodes or edges. If a suitable position can't be found after several tries, the process skips that attempt and continues elsewhere, increasing randomness.\n- The final structure is a non-intersecting tree where each node contains a randomly selected character from a predefined character set.\n- A dictionary is built, mapping each character in the character set to a list of pointers referencing all nodes containing that character.\n- To encode a message:\n  - The algorithm uses the dictionary to randomly select a node corresponding to each character.\n  - From each selected node, it backtracks to the root to generate a path (a sequence of directions).\n  - Each character in the input is replaced by its corresponding path, with paths separated by dots \"`.`\".\n- The special character \"`|`\" is used to represent whitespace.\n  - Regardless of the number of spaces in the input, all contiguous whitespace is encoded as a single \"`|`\".\n\n# How to use on Terminal\n\n| Command Name   | Terminal                             |\n|:---------------|:-------------------------------------|\n| Help           | `python -m treecrypt -h`             |\n| Version        | `python -m treecrypt -v`             |\n| Key Generation | `python -m treecrypt keygen {args}`  |\n| Encryption     | `python -m treecrypt encrypt {args}` |\n| Decryption     | `python -m treecrypt decrypt {args}` |\n\n## Key Generation arguments\n| Argument Name | Terminal  | Type    | Value                                            | Required |\n|:--------------|:---------:|:-------:|:----------------------------------------------------|:-----:|\n| Key           | `-k`      | String  | File Path to output the encryption key              | True  |\n| Dictionary    | `-d`      | String  | File Path to output the encryption dictionary       | True  |\n| Depth         | `--depth` | Integer | Key Generator depth                                 | True  |\n| Min           | `--min`   | Integer | Minimum distance between connected nodes            | False |\n| Max           | `--max`   | Integer | Maximum distance between connected nodes            | False |\n| Charset       | `-c`      | String  | File path to a python list of the charset           | False |\n| Live Print    | `-l`      | Flag    | no_Value, Prints the number of nodes generated live | False |\n\n## Encryption/Decryption arguments\n| Argument Name | Terminal | Type   | Value                                           | Required     |\n|:--------------|:--------:|:------:|:------------------------------------------------|:------------:|\n| Key           | `-k`     | String | File Path to the encryption key                 | True         |\n| Dictionary    | `-d`     | String | File Path to the encryption dictionary          | True         |\n| Input         | `-i`     | String | Input plain text to encrypt/decrypt             | `-i` or `-f` |\n| File          | `-f`     | String | File path to plain text file to encrypt/decrypt | `-i` or `-f` |\n| Output        | `-o`     | String | File path to store results                      | False        |\n\n# How to use in Code\n\n## 0. Install\nInstall it by simply running\n```shell\npip install treecrypt\n```\n\n## 1. Import\n\nInside your python code add the line\n```python\nfrom treecrypt import KeyMaker, Crypter\n```\n\nThis will import the key generator and the crypt-maker as classes and these can be used to do the encryption\n\n## 2. Create a key\nIf you already have the key and dictionary, then skip to step 4\n\nFirst of all you need a charset.\n\nThe charset used must be a list of characters which are exactly one letter and are eligible to be a python dictionary's  key\n\n```python\ncustomCharset = ['A' , 'B', 'C', ....]\nmyKeyMaker = KeyMaker(customCharset)\n```\n\nIf you don't give any parameters then the following is used:\n```python\nDefaultCharset = [\n  'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',\n  'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',\n  '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',\n  '!', '@', '#', '$', '%', '^', '\u0026', '*', '(', ')', '-', '_', '+', '=', '{', '}', '[', ']', '|', ':', ';', '\"', \"'\", ',', '.', '?', '/'\n]\n```\n\nThen generate the key using\n\n```python\nmyKeyMaker.GenerateKey(20, 10, 5)\n\n# Note the format of the parameters\ndef GenerateKey(self, Depth, MaxDistance, MinDistance = 0):\n\n# You can ignore the last parameter since it has a default value\n```\n\nThe parameters are the depth of the tree and the maximum \u0026 minimum distance between connected nodes.\n\n## 3. Export the key\nNow you can export the key as a .txt file\n\n```python\nmyKeyMaker.Export(\"KEY1.txt\", \"DICT1.txt\")\n\n# Note the format of the parameters\ndef Export(self, keyFile=\"key.txt\", dictFile=\"dict.txt\"):\n# You can ignore the parameters as they have defaults\n```\n\nYou can also get them directly inside the code using\n```python\nKey = myKeyMaker.GetKey()\nDictionary = myKeyMaker.Dictionary()\n```\n\nThe parameters are the filenames of the exported key and dictionary.\n\n## 4. Create a crypter and Import the key\nUsing the Crypter class, create an object that will encrypt and decrypt text using the previously exported key. If you already have a key then you can skip to over here.\n\nRemember that a text can only be decrypted using the same key with which it was encrypted.\n\n```python\nmyCrypter = Crypter()\nmyCrypter.Import(\"KEY1.txt\", \"DICT1.txt\")\n\n# Make sure that you are using the correct file names for import\n\ndef Import(self, keyFile=\"key.txt\", dictFile=\"dict.txt\"):\n# Import uses same format as Export of KeyMaker\n# You can ignore the parameters if the inputs have the default file names\n```\n\nAdditionally, if you only have the key and no dictionary then just do:\n\n```python\nimport ast\nwith open('KEY1.txt') as f:\n  # Use ast literal eval\n  myCrypter.SetKey(ast.literal_eval(f.readline()))\n```\n\n## 5. Start Crypting!!\nNow you can encrypt and decrypt as you wish. However make sure the input doesn't contain anything outside of the custom charset used by the KeyMaker\n\n```python\ncipher = myCrypter.Encrypt(\"TreeCrypt is AMAZING\")\ndoubleCheck = myCrypter.Decrypt(cipher)\n\nprint(cipher)\nprint(doubleCheck)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmumarshahbaz%2Ftreecrypt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmumarshahbaz%2Ftreecrypt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmumarshahbaz%2Ftreecrypt/lists"}