{"id":22660870,"url":"https://github.com/cuhsat/practical","last_synced_at":"2025-03-29T08:25:01.568Z","repository":{"id":29200054,"uuid":"32731340","full_name":"cuhsat/practical","owner":"cuhsat","description":"A one-time pad variant for easy manual application.","archived":false,"fork":false,"pushed_at":"2018-01-09T07:56:28.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-03T22:43:25.047Z","etag":null,"topics":["algorithm","cipher","cryptography","one-time-pad","one-time-pad-cipher","practical","python","strong"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cuhsat.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":"2015-03-23T12:39:18.000Z","updated_at":"2022-03-25T22:06:49.000Z","dependencies_parsed_at":"2022-08-17T19:55:10.654Z","dependency_job_id":null,"html_url":"https://github.com/cuhsat/practical","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuhsat%2Fpractical","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuhsat%2Fpractical/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuhsat%2Fpractical/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuhsat%2Fpractical/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cuhsat","download_url":"https://codeload.github.com/cuhsat/practical/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246158460,"owners_count":20732809,"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":["algorithm","cipher","cryptography","one-time-pad","one-time-pad-cipher","practical","python","strong"],"created_at":"2024-12-09T11:12:39.804Z","updated_at":"2025-03-29T08:25:01.539Z","avatar_url":"https://github.com/cuhsat.png","language":"Python","readme":"# The Practical Cipher ![Build](https://img.shields.io/travis/cuhsat/practical.svg) \nA one-time pad variant for easy manual application. Based on a 6x6 conversion\ntable supporting alphanumeric symbols. Random key generation can be done with\none normal gambling dice (d6).\n\nAn implementation in Python is provided.\n\n## Specification\n\n### Conversion Table\nThe conversion table uses a 6x6 alphanumeric matrix. It is filled from left\nto right and from top to bottom with the uppercase latin letters of the\nalphabet from `A` to `Z` and than the numbers from `0` to `9`.\n\n\u003e Please note, the _x_ and _y_ indices start at zero.\n\nThe conversion table with the default symbol arrangement:\n```\n    0 1 2 3 4 5\n\n0   A B C D E F\n1   G H I J K L\n2   M N O P Q R\n3   S T U V W X\n4   Y Z 0 1 2 3\n5   4 5 6 7 8 9\n```\n\u003e The used symbols might be replaced with `meta` symbols e.g. like `not`,\n\u003e which might alter prior or following statements.\n\n### Encryption\nEncryption is done in six easy steps:\n\n1. Convert the key and plain text symbol to its _x_ and _y_ positions\n2. Add the keys _x_ position to the plain texts _x_ position\n3. Add the keys _y_ position to the plain texts _y_ position\n4. Divide the _x_ position by _6_ and use the remainder as the new _x_ position\n5. Divide the _y_ position by _6_ and use the remainder as the new _y_ position\n6. Convert the so calculated _x_ and _y_ positions to the cipher text symbol\n\nRepeat with the next symbol if needed.\n\n#### Example\n```\n   H  E  L  L  O  Plain text (symbols)\n  11 04 15 15 22  Plain text (positions)\n\n   X  X  X  X  X  Key (symbols)\n+ 35 35 35 35 35  Key (positions)\n\n   Y  V  2  2  5  Cipher text (symbols)\n= 40 33 44 44 51  Cipher text (positions)\n```\n\n### Decryption\nDecryption is done in six easy steps:\n\n1. Convert the key and cipher text symbol to its _x_ and _y_ positions\n2. Substract the keys _x_ position from the cipher texts _x_ position\n3. Substract the keys _y_ position from the cipher texts _y_ position\n4. Divide the _x_ position by _6_ and use the remainder as the new _x_ position\n5. Divide the _y_ position by _6_ and use the remainder as the new _y_ position\n6. Convert the so calculated _x_ and _y_ positions to the plain text symbol\n\nRepeat with the next symbol if needed.\n\n#### Example\n```\n   Y  V  2  2  5  Cipher text (symbols)\n  40 33 44 44 51  Cipher text (positions)\n\n   X  X  X  X  X  Key (symbols)\n- 35 35 35 35 35  Key (positions)\n\n   H  E  L  L  O  Plain text (symbols)\n= 11 04 15 15 22  Plain text (positions)\n```\n\n### Key Generation\nKey generation is done in three easy steps:\n\n1. Throw a six-sided gambling dice, use the result minus _1_ as the _x_ position\n2. Throw a six-sided gambling dice, use the result minus _1_ as the _y_ position\n3. Convert the _x_ and _y_ positions to the key symbol\n\nRepeat with the next symbol if needed.\n\n\u003e It is advised to separate the key into blocks of five symbols for better\n\u003e readability and therefor a lesser chance of encryption/decryption errors.\n\nFor more information on randomness, please see [1].\n\n#### On Key Distribution\nKey distribution should be done directly after the key generation. It is\nadvised to create the keys by hand. Write down the generated keys to two\npieces of paper or books. The pages can be marked with page numbers for\neasier locating of the key blocks later.\n\n\u003e It is advised to not use a computer system or any other electronic device to\n\u003e generate or distribute the keys.\n\n#### On Key Synchronization\nIn order for both peers to refer to the same key, the keys to use must be\nsynchronized between each message. The simplest way to do so is using a key\nbook and referring to the used key by the page number.\n\n### Security Considerations\nThere are a few points to consider, to ensure maximal confidentiality:\n\n* Every key *must* be kept secret\n* Every key *must not* be used twice\n* Every peer *must* destroy the key directly after usage\n* Only two peers *should* have the same key\n\n## Implementation\n\n### Usage\n```$ practical.py COMMAND [KEY TEXT...]```\n\nAvailable commands:\n* `-e, --encrypt`\n* `-d, --decrypt`\n* `-k, --key`\n\n#### Example\n```\n$ practical.py --encrypt XXXXX HELLO\n```\n```\n$ practical.py --decrypt XXXXX YV255\n```\n```\n$ practical.py --key\n```\n\n### Exports\nThis Python script exports the `Practical` class.\n\n#### Practical.encrypt(text, key)\nReturns the given `text` encrypted with the given `key` as string.\n\n#### Practical.decrypt(text, key)\nReturns the given `text` decrypted with the given `key` as string.\n\n#### Practical.key(size=5, cols=5, rows=15)\nReturns a new random key of the given `size`, `cols` and `rows` as string.\n\n#### Example\n```python\nfrom practical import Practical\n\npractical = Practical()\n\nprint(practical.encrypt(\"HELLO\", \"XXXX\"))\nprint(practical.decrypt(\"YV255\", \"XXXX\"))\nprint(practical.key())\n```\n\n## License\nThis is free and unencumbered software released into the public domain.\n\nAnyone is free to copy, modify, publish, use, compile, sell, or distribute\nthis software, either in source code form or as a compiled binary, for any\npurpose, commercial or non-commercial, and by any means.\n\n----\n[1] [Randomness for Crypto](https://www.cs.berkeley.edu/~daw/rnd/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuhsat%2Fpractical","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuhsat%2Fpractical","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuhsat%2Fpractical/lists"}