{"id":20552064,"url":"https://github.com/mjvl/csci-462-tools","last_synced_at":"2026-04-16T21:07:07.768Z","repository":{"id":115923304,"uuid":"300791231","full_name":"MJVL/CSCI-462-Tools","owner":"MJVL","description":"Collection of miscellaneous scripts written to help for CSCI-462 - RIT's cryptography course.","archived":false,"fork":false,"pushed_at":"2020-12-04T01:52:09.000Z","size":81,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-09T07:43:37.626Z","etag":null,"topics":["cryptography","csci-462","diffie-hellman","dsa","elgamal","elgamal-digital-signature","rit-cryptography-course","rit-csci-462","square-and-multiply"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MJVL.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":"2020-10-03T03:57:28.000Z","updated_at":"2022-06-27T17:56:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"2cf6734c-13d3-442b-957d-8afd94f8ed16","html_url":"https://github.com/MJVL/CSCI-462-Tools","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MJVL/CSCI-462-Tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MJVL%2FCSCI-462-Tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MJVL%2FCSCI-462-Tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MJVL%2FCSCI-462-Tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MJVL%2FCSCI-462-Tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MJVL","download_url":"https://codeload.github.com/MJVL/CSCI-462-Tools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MJVL%2FCSCI-462-Tools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31904123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["cryptography","csci-462","diffie-hellman","dsa","elgamal","elgamal-digital-signature","rit-cryptography-course","rit-csci-462","square-and-multiply"],"created_at":"2024-11-16T02:34:58.902Z","updated_at":"2026-04-16T21:07:07.686Z","avatar_url":"https://github.com/MJVL.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CSCI-462-Tools\n\nCollection of miscellaneous scripts written to help for CSCI-462 - RIT's cryptography course.\n\nMost of these scripts are built for convenience, not efficient run times/memory usage, hence the code style won't be pristine.\n\n## Installation\n\n```\nsudo python3 setup.py install\n```\n\n## Script Glossary\n- [square-and-multiply](#square-and-multiply)\n  - [Usage](#usage)\n  - [Examples](#examples)\n- [dhke](#dhke)\n  - [Usage](#usage-1)\n  - [Examples](#examples-1) \n- [elgamal-digital-signature](#elgamal-digital-signature)\n  - [Usage](#usage-2)\n  - [Examples](#examples-2)\n- [dsa](#dsa)\n  - [Usage](#usage-3)\n  - [Examples](#examples-3)\n- [caesar-shift-cipher](#caesar-shift-cipher)\n  - [Usage](#usage-4)\n  - [Examples](#examples-4)\n- [irreducible-polynomials](#irreducible-polynomials)\n  - [Usage](#usage-5)\n  - [Example](#example)\n\n## square-and-multiply\n\n### Usage\n\n```\nusage: square-and-multiply [-h] [-s] base exponent modulus\n\nImplementation of the square-and-multiply algorithm, a fast method of modular\nexponentiation.\n\npositional arguments:\n  base              the base to convert to binary\n  exponent          the exponent\n  modulus           the modulus\n\noptional arguments:\n  -h, --help        show this help message and exit\n  -s, --show-steps  show each step in the algorithm\n```\n\n### Examples\n\n```\nsquare-and-multiply 3 197 101\n\n3^197 mod 101 = 15\n```\n\n```\nsquare-and-multiply 2 79 101 -s\n\n+-------------------------------------------------+\n|            Work for 2^79 mod 101 = 42           |\n+--------------+----------+-------------+---------+\n| Binary Digit |   Work   |  Operation  | mod 101 |\n+--------------+----------+-------------+---------+\n|      1       |    2     |     N/A     |    2    |\n|      0       |   2^2    |      SQ     |    4    |\n|      0       |   4^2    |      SQ     |    16   |\n|      1       | 16^2 * 2 | SQ and Mult |    7    |\n|      1       | 7^2 * 2  | SQ and Mult |    98   |\n|      1       | 98^2 * 2 | SQ and Mult |    18   |\n|      1       | 18^2 * 2 | SQ and Mult |    42   |\n+--------------+----------+-------------+---------+\n```\n\n## dhke\n\n### Usage\n\n```\nusage: dhke [-h] [-s] p α sec_a sec_b\n\nWalks through the Diffie-Hellman Key Exchange setup process.\n\npositional arguments:\n  p                 large prime p\n  α                 integer α ∈ {2, 3, ..., p - 2}\n  sec_a             secret integer exponent a\n  sec_b             secret integer exponent b\n\noptional arguments:\n  -h, --help        show this help message and exit\n  -s, --show_steps  show intermediate calculations and equations\n```\n\n### Examples\n\n```\ndhke 306 5 7 17 \n\nDomain Parameters (p, α) = (306, 5)\n\nPrivate Keys (a, b) = (7, 17)\n\nPublic Keys (A, B) = (95, 209)\n\nSession Key (AB) = 299\n```\n\n```\ndhke 29 2 5 12 -s\n\nDomain Parameters (p, α) = (29, 2)\n\nPrivate Keys (a, b) = (5, 12)\n\nA = α^a mod p\n\t3 = 2^5 mod 29\n\nB = α^b mod p\n\t7 = 2^12 mod 29\n\nPublic Keys (A, B) = (3, 7)\n\nAB = A^b mod p\n\t16 = 3^12 mod 29\n\nAB = B^a mod p\n\t16 = 7^5 mod 29\n\nAB = α^ab mod p\n\t16 = 2^(5 * 12) mod 29\n\nSession Key (AB) = 16\n```\n\n## elgamal-digital-signature\n\n### Usage\n\n```\nusage: elgamal-digital-signature [-h] [-s] d p α x kE\n\nWalks through the Elgamal Digital Signature process and checks if the\nsignature is valid.\n\npositional arguments:\n  d                 the private key, a random integer d ∈ {2, 3, ..., p - 2}\n  p                 large prime p\n  α                 primitive root α\n  x                 message\n  kE                random ephemeral key kE ∈ {0, 1, 2,.., p − 2} such that\n                    gcd(kE, p − 1) = 1\n\noptional arguments:\n  -h, --help        show this help message and exit\n  -s, --show_steps  show intermediate calculations and equations\n```\n\n### Examples\n\n```\nelgamal-digital-signature 67 97 23 85 77\n\nPublic Key (p, α, β) = (97, 23, 15)\n\nElgamal Signature (x, (r, s)) = (85, (84, 29))\n\nVerification (t, α^x) = (83, 83)\n\nValid Signature\n```\n\n```\nelgamal-digital-signature 12 29 2 26 5 -s\n\nChoose d = 12\nChoose p = 29\nChoose α = 2\n\nβ = α^d mod p:\n\t7 = 2^12 mod 29\n\nPublic Key (p, α, β) = (29, 2, 7)\n\nChoose x = 26\nChoose kE = 5\n\nr = α^kE mod p - 1:\n\t3 = 2^5 mod 28\n\ns = (x - dr)kE^-1 mod p - 1:\n\t26 = (26 - (12 * 3)) * 17 mod 28\n\nElgamal Signature (x, (r, s)) = (26, (3, 26))\n\nt = β^r * r^s mod p:\n\t22 = 7^3 * 3^26 mod 29\n\nα^x mod p:\n\t22 = 2^26 mod 29\n\nVerification (t, α^x) = (22, 22)\n\nValid Signature\n```\n\n## dsa\n\n### Usage\n\n```\nusage: dsa [-h] [-s] p q α d hx kE\n\nWalks through the Digital Signature Algorithm process and checks if the\nsignature is valid.\n\npositional arguments:\n  p                 prime p\n  q                 divisor of p - 1\n  α                 element with ord(α) = q\n  d                 the private key with 0 \u003c d \u003c q\n  h(x)              the hash of the message x\n  kE                random ephemeral key with 0 \u003c kE \u003c q\n\noptional arguments:\n  -h, --help        show this help message and exit\n  -s, --show_steps  show intermediate calculations and equations\n```\n\n### Examples\n\n```\ndsa 59 29 3 7 17 25\n\nPublic Key (p, q, α, β) = (59, 29, 3, 4)\n\nDSA Signature (h(x), (r, s)) = (17, (22, 8))\n\nVerification (v, r mod q) = (22, 22)\n\nValid Signature\n```\n\n```\ndsa 59 29 3 7 26 10 -s\n\nChoose d = 7\nChoose p = 59\nChoose q = 29\nChoose α = 3\n\nβ = α^d mod p:\n\t4 = 3^7 mod 59\n\nPublic Key (p, q, α, β) = (59, 29, 3, 4)\n\nCompute h(x) = 26\nChoose kE = 10\n\nr = (α^kE mod p) mod q\n\t20 = (3^10 mod 59) mod 29\n\ns = (h(x) + dr)kE^-1 mod q\n\t5 = (26 - (7 * 20)) * 3 mod 29\n\nDSA Signature (h(x), (r, s)) = (26, (20, 5))\n\nw = s^-1 mod q\n\t6 = 5^-1 mod 29\n\nu1 = w * h(x) mod q\n\t11 = 6 * 26 mod 29\n\nu2 = w * r mod q\n\t4 = 6 * 20 mod 29\n\nv = (α^u1 * β^u2 mod p) mod q\n\t20 = (3^11 * 4^4 mod 59) mod 29`\n\nVerification (v, r mod q) = (20, 20)\n\nValid Signature\n```\n\n## caesar-shift-cipher\n\n### Usage\n\n```\nusage: caesar-shift-cipher [-h] [-k KEY] text\n\nImplements basic ASCII encryption/decryption through a Ceasar cipher, as well\nas brute forcing.\n\npositional arguments:\n  text               the plaintext or ciphertext to encrypt or decrypt\n                     respectively\n\noptional arguments:\n  -h, --help         show this help message and exit\n  -k KEY, --key KEY  the shift (if known, no value = brute force)\n```\n\n### Examples\n\n```\ncaesar-shift-cipher xultpaajcxitltlxaarpjhtiwtgxktghidhipxciwtvgtpilpitghlxiwiwtxgqadds -k 11\n\nShifted: ifweallunitewewillcausetheriverstostainthegreatwaterswiththeirblood\n```\n\n```\ncaesar-shift-cipher \"freq analysis\"\n\n+-------+---------------+\n| Shift |      Text     |\n+-------+---------------+\n|   0   | freq analysis |\n|   1   | gsfr bobmztjt |\n|   2   | htgs cpcnauku |\n|   3   | iuht dqdobvlv |\n|   4   | jviu erepcwmw |\n|   5   | kwjv fsfqdxnx |\n|   6   | lxkw gtgreyoy |\n|   7   | mylx huhsfzpz |\n|   8   | nzmy ivitgaqa |\n|   9   | oanz jwjuhbrb |\n|   10  | pboa kxkvicsc |\n|   11  | qcpb lylwjdtd |\n|   12  | rdqc mzmxkeue |\n|   13  | serd nanylfvf |\n|   14  | tfse obozmgwg |\n|   15  | ugtf pcpanhxh |\n|   16  | vhug qdqboiyi |\n|   17  | wivh rercpjzj |\n|   18  | xjwi sfsdqkak |\n|   19  | ykxj tgterlbl |\n|   20  | zlyk uhufsmcm |\n|   21  | amzl vivgtndn |\n|   22  | bnam wjwhuoeo |\n|   23  | cobn xkxivpfp |\n|   24  | dpco ylyjwqgq |\n|   25  | eqdp zmzkxrhr |\n+-------+---------------+\n```\n\n## irreducible-polynomials\n\n### Usage\n\n```\nusage: irreducible-polynomials [-h] [-r] degree\n\nFinds all irreducible (and optionally reducible) polynomials up to a specified\ndegree in Z2.\n\npositional arguments:\n  degree           degree to find irreducible polynomials up to\n\noptional arguments:\n  -h, --help       show this help message and exit\n  -r, --reducible  include reducible polynomials\n```\n\n### Example\n\n```\nirreducible-polynomials 2 -r\n\nPolynomials up to Degree 2 in Z2\n---------------------\nReducible Polynomials\n---------------------\nx^2\nx^2 + 1\nx^2 + x\n-----------------------\nIrreducible Polynomials\n-----------------------\nx\nx + 1\nx^2 + x + 1\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjvl%2Fcsci-462-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjvl%2Fcsci-462-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjvl%2Fcsci-462-tools/lists"}