{"id":23161243,"url":"https://github.com/memergamer/textbook-rsa-python","last_synced_at":"2025-04-04T19:29:00.217Z","repository":{"id":267603210,"uuid":"901762047","full_name":"MemerGamer/Textbook-RSA-Python","owner":"MemerGamer","description":"Python implementation for the Textbook RSA algorithm","archived":false,"fork":false,"pushed_at":"2024-12-11T09:25:45.000Z","size":4,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-10T04:29:45.556Z","etag":null,"topics":["python","rsa","rsa-algorithm","textbook-rsa"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MemerGamer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-12-11T09:13:11.000Z","updated_at":"2024-12-11T09:27:23.000Z","dependencies_parsed_at":"2024-12-11T10:29:21.110Z","dependency_job_id":"c6c6247a-36d4-4875-9b0e-ab60e8cd93d2","html_url":"https://github.com/MemerGamer/Textbook-RSA-Python","commit_stats":null,"previous_names":["memergamer/textbook-rsa-python"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MemerGamer%2FTextbook-RSA-Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MemerGamer%2FTextbook-RSA-Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MemerGamer%2FTextbook-RSA-Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MemerGamer%2FTextbook-RSA-Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MemerGamer","download_url":"https://codeload.github.com/MemerGamer/Textbook-RSA-Python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247237135,"owners_count":20906241,"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":["python","rsa","rsa-algorithm","textbook-rsa"],"created_at":"2024-12-17T23:13:43.910Z","updated_at":"2025-04-04T19:29:00.190Z","avatar_url":"https://github.com/MemerGamer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Textbook RSA Implementation in Python\n\nThis project implements a basic version of the RSA algorithm, a foundational public-key cryptosystem, in Python. The implementation uses only built-in Python modules and commands for simplicity and educational purposes.\n\n## Features\n\n- **Key Generation**: Generate public and private keys based on user-defined bit lengths.\n- **Encryption**: Encrypt plaintext messages using the public key.\n- **Decryption**: Decrypt ciphertext messages using the private key.\n- **Prime Number Generation**: Use the Miller-Rabin primality test to ensure secure key generation.\n\n## Files\n\n- `rsa.py`: Contains the implementation of the RSA algorithm, including functions for key generation, encryption, and decryption.\n- `main.py`: Demonstrates the usage of the RSA algorithm by generating keys, encrypting a message, and decrypting it.\n\n## Prerequisites\n\n- Python 3.x\n\n## Example Usage\n\nTo see the RSA algorithm in action, run the `main.py` script:\n\n```bash\npython main.py\n```\n\n### Example Output\n\n```text\nPublic Key: (e, n)\n--------------------\nPrivate Key: (d, n)\n--------------------\nCiphertext: [...]\n--------------------\nDecrypted Message: Hello, RSA!\n```\n\n## How It Works\n\n1. **Key Generation**: The `generate_keys` function generates a pair of keys. Large prime numbers are chosen, and their product determines the modulus (`n`). The public exponent (`e`) and private exponent (`d`) are computed such that they satisfy the modular arithmetic constraints of the RSA algorithm.\n\n2. **Encryption**: The `encrypt` function converts the plaintext message into a list of integers (Unicode code points) and applies modular exponentiation using the public key.\n\n3. **Decryption**: The `decrypt` function reverses the encryption process using the private key to recover the original message.\n\n## Educational Note\n\nThis implementation follows the textbook RSA algorithm for simplicity. It is not secure for production use as it does not include padding mechanisms such as OAEP (Optimal Asymmetric Encryption Padding), which are critical for modern RSA security.\n\nFor any questions or contributions, feel free to submit a pull request or raise an issue in the repository.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmemergamer%2Ftextbook-rsa-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmemergamer%2Ftextbook-rsa-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmemergamer%2Ftextbook-rsa-python/lists"}