{"id":20884597,"url":"https://github.com/adam-mcdaniel/rsa","last_synced_at":"2025-05-12T18:31:29.520Z","repository":{"id":232502266,"uuid":"784510076","full_name":"adam-mcdaniel/rsa","owner":"adam-mcdaniel","description":"An RSA🔐 implementation in C, using arbitrarily large integers","archived":false,"fork":false,"pushed_at":"2024-04-23T21:11:51.000Z","size":1031,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T10:01:44.296Z","etag":null,"topics":["c","cybersecurity","decryption","encryption","header-only","library","rsa-cryptography"],"latest_commit_sha":null,"homepage":"https://adam-mcdaniel.net","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/adam-mcdaniel.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}},"created_at":"2024-04-10T01:42:16.000Z","updated_at":"2025-02-04T14:39:28.000Z","dependencies_parsed_at":"2024-04-23T22:28:31.169Z","dependency_job_id":null,"html_url":"https://github.com/adam-mcdaniel/rsa","commit_stats":null,"previous_names":["adam-mcdaniel/rsa"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Frsa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Frsa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Frsa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Frsa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adam-mcdaniel","download_url":"https://codeload.github.com/adam-mcdaniel/rsa/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253798085,"owners_count":21966003,"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":["c","cybersecurity","decryption","encryption","header-only","library","rsa-cryptography"],"created_at":"2024-11-18T08:10:37.232Z","updated_at":"2025-05-12T18:31:28.790Z","avatar_url":"https://github.com/adam-mcdaniel.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rsa\n\n![Header Image](assets/header.png)\n\nThis repository implements the RSA algorithm in C, with arbitarily large integers. The implementation uses [a custom bigint library](https://github.com/adam-mcdaniel/bigint) to handle large key sizes.\n\nThe library is header-only, and can be included in any C project.\n\nIt has support for generating keys and encrypting/decrypting messages.\n\n## Usage\n\nTo use the library, first include it in your C file.\n\n```c\n#include \"rsa.h\"\n```\n\nThen, generate a public/private key pair using the `generate_key_pair` function.\n\n```c\nint main() {\n    bigint p1 = bigint_from_string(\"61\");\n    bigint p2 = bigint_from_string(\"53\");\n    bigint n, t, e, d;\n\n    generate_key_pair(p1, p2, \u0026n, \u0026t, \u0026e, \u0026d);\n    printf(\"Public key: \");\n    bigint_print(e);\n\n    printf(\"\\nPrivate key: \");\n    bigint_print(d);\n\n    return 0;\n}\n```\n\nThen, use the `encrypt_text` and `decrypt_text` functions to encrypt and decrypt messages.\n\n```c\nint main() {\n    bigint p1 = bigint_from_string(\"61\");\n    bigint p2 = bigint_from_string(\"53\");\n    bigint n, t, e, d;\n\n    generate_key_pair(p1, p2, \u0026n, \u0026t, \u0026e, \u0026d);\n    printf(\"Public key: \");\n    bigint_print(e);\n\n    printf(\"\\nPrivate key: \");\n    bigint_print(d);\n\n    char message[] = \"Hello, world!\";\n    bigint *encrypted = encrypt_text(message, e, n);\n    char *decrypted = decrypt_text(encrypted, strlen(message), d, n);\n\n    printf(\"\\nEncrypted: \");\n    for (int i = 0; i \u003c strlen(message); i++) {\n        bigint_print(encrypted[i]);\n        printf(\" \");\n    }\n    printf(\"\\nDecrypted: %s\\n\", decrypted);\n\n    return 0;\n}\n```\n\n## Building\n\nTo build your program with the RSA library, simply add it to your include path, [along with the bigint header file](https://github.com/adam-mcdaniel/bigint), and link against the C standard library.\n\n```bash\ngcc -I path/to/rsa -I path/to/bigint main.c -o main\n```\n\n### CMake\n\nTo build with CMake, you can use a `CMakeLists.txt` file like the following:\n\n```cmake\ncmake_minimum_required(VERSION 3.0)\n\n# Create a new project\nproject(HelloWorld)\n\n# Add an executable\nadd_executable(HelloWorld main.c)\n\ninclude_directories(path/to/rsa)\ninclude_directories(path/to/bigint)\n```\n\nAlternatively, you can use `FetchContent` to download the RSA and Bigint repositories and include them in your project.\n\n```cmake\n# Import the library from the git repo\ninclude(FetchContent)\n\nFetchContent_Declare(\n  rsa\n  GIT_REPOSITORY https://github.com/adam-mcdaniel/rsa\n  GIT_TAG        main\n)\n\nFetchContent_MakeAvailable(rsa)\n\n# Include the header only library\ninclude_directories(${rsa_SOURCE_DIR})\n\n# Do the same for the bigint project\nFetchContent_Declare(\n  bigint\n  GIT_REPOSITORY https://github.com/adam-mcdaniel/bigint\n  GIT_TAG        main\n)\n\nFetchContent_MakeAvailable(bigint)\n\n# Include the header only library\ninclude_directories(${bigint_SOURCE_DIR})\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadam-mcdaniel%2Frsa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadam-mcdaniel%2Frsa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadam-mcdaniel%2Frsa/lists"}