{"id":19016222,"url":"https://github.com/fosskers/enigma","last_synced_at":"2025-09-13T19:04:29.823Z","repository":{"id":66324968,"uuid":"79690735","full_name":"fosskers/enigma","owner":"fosskers","description":"An encryption algorithm inspired by the Enigma Machine.","archived":false,"fork":false,"pushed_at":"2017-02-16T18:14:09.000Z","size":13,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-01T23:11:46.939Z","etag":null,"topics":["encryption-algorithm","enigma-machine","haskell"],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fosskers.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog.md","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":"2017-01-22T03:26:27.000Z","updated_at":"2023-05-31T13:57:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"096658fe-4d41-4917-9155-65f7a43993ff","html_url":"https://github.com/fosskers/enigma","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/fosskers%2Fenigma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fosskers%2Fenigma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fosskers%2Fenigma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fosskers%2Fenigma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fosskers","download_url":"https://codeload.github.com/fosskers/enigma/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240059510,"owners_count":19741670,"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":["encryption-algorithm","enigma-machine","haskell"],"created_at":"2024-11-08T19:41:41.546Z","updated_at":"2025-02-21T17:37:05.541Z","avatar_url":"https://github.com/fosskers.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"Enigma\n======\n\n[![Build Status](https://travis-ci.org/fosskers/enigma.svg?branch=master)](https://travis-ci.org/fosskers/enigma)\n\n**Note:** This algorithm [has been\nshown](https://www.reddit.com/r/crypto/comments/5tudkl/a_modernized_enigma_algorithm/)\nto be utter garbage as-is, please do not use it for anything.\n\nThis library provides a symmetric key encryption algorithm inspired by the\nfamous [*Enigma Machine*](https://en.wikipedia.org/wiki/Enigma_machine) used\nby Nazi Germany in World War 2. The original machine had two main hardware\ndeficiencies that allowed the Allies to eventually crack it:\n\n1. To keep the machine small, it only had 3 (or 4, depending on the model)\nmechanical *Rotors* which each mapped an input value to some output. Wired\ntogether, these Rotors would map input letters pressed on a keyboard to\noutput letters. With each input the Rotors would advance, changing the\nmapping. However, with so few Rotors, the amount of obfuscation steps that\nit could perform were limited.\n\n2. To address the above problem, the designers of the Enigma decided to have\nthe output of the last Rotor feed back into itself, winding its way back\nthrough the machine. This artificially extends the Rotor count, but also\nproved to be the critical flaw.\n\nMore detailed explanations of the original machine can be easily found on\nthe internet.\n\nThis library takes the following approach:\n\n1. It works on bits, not characters.\n2. The 26-letter Rotors are reduced to 2 possible bit transformations, \"id\" and \"flip\".\n3. We represent a single rotor as a single bit. 0 is \"id\", 1 is \"flip\".\n4. The entire machine (group of rotors) is represented by a series of bits.\n5. Like the original Enigma, our secret key is the initial state of the rotors,\n   which is just a series of bits. It can thus be arbitrarily long to offer\n   many many obfuscation steps.\n6. Like the original Enigma, each input (bit) is encrypted with a different key (rotor set).\n7. Like the original Enigma, the ciphering algorithm both encrypts and decrypts.\n8. The ciphering algorithm doesn't feed back into itself.\n\nExamples\n--------\n\nEncrypt a `Word64`:\n```haskell\nλ evalState (cipher 1) $ Key 1\n6513794518609451620\n```\n\nDecrypt a `Word64`:\n```haskell\nλ evalState (cipher 6513794518609451620) $ Key 1\n1\n```\n\nChain encryptions, carrying over the rotor state between operations:\n```haskell\nλ evalState ((,) \u003c$\u003e cipher 1 \u003c*\u003e cipher 2) $ Key 1\n(6513794518609451620,7321263536672712088)\n```\n\nEncrypt a `Foldable`:\n```haskell\nλ evalState (traverse cipher [1,2,3]) $ Key 1\n[6513794518609451620,7321263536672712088,11932949555100099993]\n```\n\nEncrypt a message:\n```haskell\nλ evalState (traverse (cipher . fromIntegral . ord) \"Hint\") $ Key 1\n[6513794518609451565,7321263536672712179,11932949555100100084,6513794518609451537]\n```\n\nPerformance\n-----------\n\n(More benchmarks needed)\n\nMachine: ThinkPad X1 Carbon w/ Intel COREi7\n\nEncrypting... | Average Time\n------------- | ------------\nSingle `Word64` | 1.9 μs\n10k `Word64` | 19.5 ms\n1mil `Word64` (~7.5mb) | 1.95 s\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffosskers%2Fenigma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffosskers%2Fenigma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffosskers%2Fenigma/lists"}