{"id":16949459,"url":"https://github.com/kreusada/charabia","last_synced_at":"2025-04-11T20:20:34.599Z","repository":{"id":62561768,"uuid":"437382410","full_name":"Kreusada/Charabia","owner":"Kreusada","description":"Library designed for reversible sheltering of sensitive information/data, meaning you can shelter strings or tokens using this encoder.","archived":false,"fork":false,"pushed_at":"2022-01-20T19:50:55.000Z","size":16,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T15:12:59.836Z","etag":null,"topics":["decoder","encoder","encoder-decoder","encryption-decryption","sensitive-data"],"latest_commit_sha":null,"homepage":"","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/Kreusada.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}},"created_at":"2021-12-11T20:30:34.000Z","updated_at":"2024-02-08T03:48:44.000Z","dependencies_parsed_at":"2022-11-03T15:15:33.226Z","dependency_job_id":null,"html_url":"https://github.com/Kreusada/Charabia","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/Kreusada%2FCharabia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kreusada%2FCharabia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kreusada%2FCharabia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kreusada%2FCharabia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kreusada","download_url":"https://codeload.github.com/Kreusada/Charabia/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248473079,"owners_count":21109629,"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":["decoder","encoder","encoder-decoder","encryption-decryption","sensitive-data"],"created_at":"2024-10-13T21:54:47.750Z","updated_at":"2025-04-11T20:20:34.565Z","avatar_url":"https://github.com/Kreusada.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Charabia\r\n\r\nThis library was designed for reversible sheltering of sensitive information/data,\r\nmeaning you can shelter strings or tokens using this encoder.\r\n\r\nCharabia gets it's name from the French of \"gibberish\", as when encoded, the\r\ntext quite literally looks like a load of gibberish.\r\n\r\n### Getting started\r\n\r\nImport the module:\r\n\r\n```py\r\nimport charabia\r\n```\r\n\r\n- `Separator Configuration`\r\n\r\n    Firstly, you should configure the encoder to use a separator configuration. Each\r\n    separator in the configuration has a chance to be the separator/splitter of each character\r\n    within the encoded string.\r\n\r\n    ```py\r\n    charabia.setseps(\"ABCDEFGH\")\r\n    ```\r\n\r\n    Alternatively, you can use a temporary configuration as a context manager by using the\r\n    `tempsep()` method (standing for temporary separators)\r\n\r\n    ```py\r\n    with charabia.tempsep(\"ABCDEFGH\"):\r\n        ...\r\n    ```\r\n\r\n    Separator duplicates and insertion order is not relevant, so it does not matter what order you provide them in\r\n    (`ABCD` == `DCBA`).\r\n\r\n- `Separator Acknowledgement`\r\n\r\n    The exact separator configuration is required in order to decode a specific string. This means\r\n    it's really important to remember the separator config you used to encode a given string. \r\n\r\n- `Encoder`\r\n\r\n    Now we have configured charabia, we can start encoding and decoding strings. For the following\r\n    examples, we will use the configuration `ABCD`.\r\n\r\n    ```py\r\n    \u003e\u003e\u003e charabia.setseps(\"ABCD\")\r\n    \u003e\u003e\u003e codes = []\r\n    \u003e\u003e\u003e for _ in range(5):\r\n    \u003e\u003e\u003e    encoded = charabia.encode(\"Hello world!\")\r\n    \u003e\u003e\u003e    print(encoded)\r\n    \u003e\u003e\u003e    codes.append(encoded)\r\n    'VGBZEvCPaWBvusAvZFAnGCbFXDZlZCbPeAvkiDFukDxH'\r\n    'VQCPYZClkWDPusAvFbCxQCvbtBPPvDFFeAbaiAbYaAHn'\r\n    'hQAbaPAPEWCZEsDvblDdcAFPjDvbbDFleCluWBZkaCRH'\r\n    'LwBluPBZusCFOsCPZbDHQAbPNBZvvCZFSAlOiClEuCxR'\r\n    'hcCZOvCvEWBPOsDFvbBHwAbbjCvFFAllSCFYWBZuOBHR'\r\n    ```\r\n\r\n    5 unique results have been produced with this separator configuration. The longer the string,\r\n    the more likely they are to be unique from other strings.\r\n\r\n    Now using the same configuration, lets decode each of the strings in the `codes` list we created.\r\n\r\n    ```py\r\n    \u003e\u003e\u003e for c in codes:\r\n    \u003e\u003e\u003e    print(charabia.decode(c))\r\n    'Hello world!'\r\n    'Hello world!'\r\n    'Hello world!'\r\n    'Hello world!'\r\n    'Hello world!'\r\n    ```\r\n\r\n    Despite being different, all these results are decoded to exactly the same original string.\r\n\r\n- `Configuration conflicts`\r\n\r\n    Charabia operates based on the separators provided in setseps, so if the incorrect separators are\r\n    given to decode a string, things may not work as expected.\r\n\r\n    Let's grab one of our results from earlier, `VGBZEvCPaWBvusAvZFAnGCbFXDZlZCbPeAvkiDFukDxH`. This\r\n    will only translate to \"Hello world!\" with the configuration `ABCD`, so lets change the configuration\r\n    and see what happens:\r\n\r\n    ```py\r\n    \u003e\u003e\u003e with charabia.tempsep(\"EFGH\"):\r\n    \u003e\u003e\u003e     print(charabia.decode(\"VGBZEvCPaWBvusAvZFAnGCbFXDZlZCbPeAvkiDFukDxH\"))\r\n    CharabiaError: failed to decode with configuration EFGH\r\n    ```\r\n    \r\n### Methods\r\n\r\n- `setseps()`\r\n\r\n    Use this function to configure the separators used for charabia. Must be alphanumeric,\r\n    and must range between 1 and 42.\r\n\r\n    ```py\r\n    charabia.setseps(\"MySeparators123\")\r\n    ```\r\n\r\n- `getseps()`\r\n\r\n    Get the separators associated with the current charabia configuration.\r\n\r\n    ```py\r\n    \u003e\u003e\u003e charabia.setseps(\"QwErTy103\")\r\n    \u003e\u003e\u003e charabia.getseps()\r\n    'QwErTy103'\r\n    \u003e\u003e\u003e charabia.setseps(\"aaaaaa\")\r\n    \u003e\u003e\u003e charabia.getseps()\r\n    'a'\r\n    ```\r\n\r\n- `tempseps()`\r\n\r\n    Context manager to temporarily alter the separator configuration.\r\n    This will fall back to the original global setting after `__exit__()`.\r\n\r\n    ```py\r\n    \u003e\u003e\u003e with charabia.tempseps(\"ABC\"):\r\n    \u003e\u003e\u003e     charabia.decode(\"ZPgCbkbCbbTCPZgCFEJAlZuCPYRARmBotBfYBfZ\")\r\n    'testing 123'\r\n    ```\r\n\r\n- `encode()`\r\n    \r\n    Use the encode method to encode standard text into charabia. Ensure that charabia is configured\r\n    before using this method.\r\n\r\n    ```py\r\n    \u003e\u003e\u003e charabia.setseps(\"AsDfGhJkL\")\r\n    \u003e\u003e\u003e charabia.encode(\"Hello world!\")\r\n    'VwklElsPuCfFuWflFPAdwJZPNAPvlAFFIGPaMhZuOAnx'\r\n    ```\r\n\r\n- `decode()`\r\n\r\n    The reverse of `encode()`. Self-explanatory, really.\r\n\r\n    ```py\r\n    \u003e\u003e\u003e charabia.setseps(\"AsDfGhJkL\")\r\n    \u003e\u003e\u003e charabia.decode(\"VwklElsPuCfFuWflFPAdwJZPNAPvlAFFIGPaMhZuOAnx\")\r\n    'Hello world!'\r\n    ```\r\n\r\n- `splitseps()`\r\n\r\n    Exposed helper function used to split a string with the current or provided\r\n    separator configuration. Seeing as this command can be used for debugging purposes,\r\n    you can pass your own configuration straight into the command if you're not wanting\r\n    to use tempseps for what you're trying to do. The options there :P\r\n\r\n    ```py\r\n    \u003e\u003e\u003e charabia.setseps(\"fioh452\")\r\n    \u003e\u003e\u003e encoded = charabia.encode(\"hello world!\")\r\n    \u003e\u003e\u003e print(encoded)\r\n    'bayhFEvibaCfbuW2bPb4dw5lZN5lFbfPlShZaWfFkaixn'\r\n    \u003e\u003e\u003e print(charabia.splitseps(encoded))\r\n    ['bay', 'FEv', 'baC', 'buW', 'bPb', 'dw', 'lZN', 'lFb', 'PlS', 'ZaW', 'Fka', 'xn']\r\n    \u003e\u003e\u003e print(charabia.splitseps(\"VwklElsPuCfFuWflFPAdwJZPNAPvlAFFIGPaMhZuOAnx\", \"AsDfGhJkL\"))\r\n    ['Vw', 'lEl', 'PuC', 'FuW', 'lFP', 'dw', 'ZPN', 'Pvl', 'FFI', 'PaM', 'ZuO', 'nx']\r\n    ```\r\n\r\n- `create_tower()`\r\n\r\n    The same as passing the `tower_rows` kwarg to `encode()`. Creates a tower for the given string.\r\n\r\n    ```py\r\n    \u003e\u003e\u003e string = \"bayhFEvibaCfbuW2bPb4dw5lZN5lFbfPlShZaWfFkaixn\"\r\n    \u003e\u003e\u003e print(charabia.create_tower(string, 10))\r\n    '''\r\n    bayhFEviba\r\n    CfbuW2bPb4\r\n    dw5lZN5lFb\r\n    fPlShZaWfF\r\n    kaixn\r\n    '''\r\n    ```\r\n\r\n- `demolish_tower()`\r\n\r\n    Removes a tower from a string.\r\n\r\n    ```py\r\n    \u003e\u003e\u003e string = \"\"\"\r\n    bayhFEviba\r\n    CfbuW2bPb4\r\n    dw5lZN5lFb\r\n    fPlShZaWfF\r\n    kaixn\r\n    \"\"\"\r\n    \u003e\u003e\u003e print(charabia.demolish_tower(string))\r\n    'bayhFEvibaCfbuW2bPb4dw5lZN5lFbfPlShZaWfFkaixn'\r\n    ```\r\n\r\n### Internal exposed methods\r\n\r\nThe following methods are only designed for internal use, but are exposed for public use if wanted.\r\n\r\n- `configured()`\r\n\r\n    Returns whether charabia is fully configured.\r\n\r\n- `generate_encoding_indexes()`\r\n\r\n    Generates the encoding indexes used for a specific configuration. This is an exposed but\r\n    internal function, so you must pass separators to it. You should only use this if you know\r\n    what you're doing, and if you know the **encode** function well.\r\n\r\n    ```py\r\n    \u003e\u003e\u003e print(charabia.generate_encoding_indexes(\"QwErTy103\"))\r\n    {\r\n        0: ['a', 'k', 'u', 'O', 'Y'],\r\n        1: ['b', 'l', 'v', 'F', 'P', 'Z'],\r\n        2: ['c', 'm', 'G'],\r\n        3: ['d', 'n', 'x', 'H', 'R'],\r\n        4: ['e', 'o', 'I', 'S'],\r\n        5: ['f', 'p', 'z', 'J'],\r\n        6: ['g', 'q', 'A', 'K', 'U'],\r\n        7: ['h', 'B', 'L', 'V'],\r\n        8: ['i', 's', 'C', 'M', 'W'],\r\n        9: ['j', 't', 'D', 'N', 'X']\r\n    }\r\n    ```\r\n\r\n- `generate_decoding_indexes()`\r\n\r\n    This is really just the same as the encode counterpart, use it in the same way.\r\n\r\n    ```py\r\n    {\r\n        'a': '0', 'k': '0', 'u': '0', 'O': '0', 'Y': '0',\r\n        'b': '1', 'l': '1', 'v': '1', 'F': '1', 'P': '1',\r\n        'Z': '1', 'c': '2', 'm': '2', 'G': '2', 'd': '3',\r\n        'n': '3', 'x': '3', 'H': '3', 'R': '3', 'e': '4',\r\n        'o': '4', 'I': '4', 'S': '4', 'f': '5', 'p': '5',\r\n        'z': '5', 'J': '5', 'g': '6', 'q': '6', 'A': '6',\r\n        'K': '6', 'U': '6', 'h': '7', 'B': '7', 'L': '7',\r\n        'V': '7', 'i': '8', 's': '8', 'C': '8', 'M': '8',\r\n        'W': '8', 'j': '9', 't': '9', 'D': '9', 'N': '9',\r\n        'X': '9', 'Q': ' ', 'w': ' ', 'E': ' ', 'r': ' ',\r\n        'T': ' ', 'y': ' ', '1': ' ', '0': ' ', '3': ' ',\r\n        '\\n': ''\r\n    }\r\n    ```\r\n\r\n### Installation\r\n\r\nInstall using the recommended installer, Pip.\r\n\r\n```sh\r\npip install charabia\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkreusada%2Fcharabia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkreusada%2Fcharabia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkreusada%2Fcharabia/lists"}