{"id":17942630,"url":"https://github.com/petercamilleri/mystiko","last_synced_at":"2026-01-21T21:33:55.831Z","repository":{"id":56885066,"uuid":"59908356","full_name":"PeterCamilleri/mystiko","owner":"PeterCamilleri","description":"A simple example encryption system with a challenge!","archived":false,"fork":false,"pushed_at":"2021-05-19T14:56:52.000Z","size":53,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-16T23:36:08.905Z","etag":null,"topics":["challenge","encryption","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/PeterCamilleri.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-28T18:11:59.000Z","updated_at":"2021-05-19T14:56:54.000Z","dependencies_parsed_at":"2022-08-20T13:50:49.928Z","dependency_job_id":null,"html_url":"https://github.com/PeterCamilleri/mystiko","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/PeterCamilleri%2Fmystiko","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterCamilleri%2Fmystiko/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterCamilleri%2Fmystiko/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterCamilleri%2Fmystiko/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PeterCamilleri","download_url":"https://codeload.github.com/PeterCamilleri/mystiko/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247809992,"owners_count":20999821,"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":["challenge","encryption","ruby"],"created_at":"2024-10-29T03:06:32.196Z","updated_at":"2026-01-21T21:33:55.771Z","avatar_url":"https://github.com/PeterCamilleri.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Mystik\u0026oacute;\n\nThe word mystik\u0026oacute; is from the Greek language and means secret. Keeping\nsecrets safe from unauthorized eyes is the very core purpose of encryption.\n\nThis gem is only intended for educational purposes and should not be used in\nserious data security applications.\n\nAny use for unlawful purposes is strictly forbidden.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'mystiko'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install mystiko\n\nThe mystiko gem itself is found at: ( https://rubygems.org/gems/mystiko )\n\n## Usage\n\nMystik\u0026oacute; is both a ruby gem and a command line utility. In order to work\nwith the encryption engine two things must be done:\n\n - An instance must be created. This is easily done with the new method.\n\nand then one of the following two options:\n\n - Encryption is done with the encrypt method and appropriate parameters.\n - Decryption is done with the decrypt method and appropriate parameters.\n\nThe parameters take the form of classical named/hashed parameters. Supported\nparameters include:\n\n - in_str: \"value\" -- a string of input data.\n - in_file: \"name\" -- the name of a file of input data. Overrides in_str.\n - key: \"value\" -- the key to use for processing\n - generator: object -- a seeded, pseudo-random number generator. Overrides key.\n - out_str: \"value\" -- the string output is appended to this string.\n - out_file: \"name\" -- the name of a file of output data. Overrides out_str.\n - window: value -- the size, in bytes, of the shuffling window.\n\nThe methods encrypt and decrypt both also return the resultant string of data.\n\nThe command line utility displays the following message if started with no\narguments or the \"--help\", \"-h\", or \"-?\" options.\n\n    Mystiko version 0.1.0\n\n    Usage summary:\n\n    $ mystiko \u003coptions\u003e\n\n    --help,    -h, -?            # Display this help message.\n    --encrypt, -e                # Data is to be encrypted.\n    --decrypt, -d                # Data is to be decrypted.\n    --input,   -i \u003cinput data\u003e   # Specify the input data string.\n    --read,    -r \u003cfile name\u003e    # Specify the input data file name.\n    --write,   -w \u003cfile name\u003e    # Specify the input data file name.\n    --key,     -k \u003ckey data\u003e     # Specify the key data string.\n\n    Notes:\n     - A command option and a key are always required.\n     - Data input defaults to STDIN.\n     - Data output defaults to STDOUT.\n     - If -r is specified, -i is ignored.\n     - String data may be optionally enclosed in \" ... \"\n\n## Principles of Operation\n\n#### The Vernam Cypher\n\nThe mystik\u0026oacute; gem is a modified Vernam cypher. The Vernam cypher works\nby taking a stream of input symbols and mapping them to output symbols. This\nmapping obscures the original data. The classic approach to this type of cypher\nis to have a random string of data of the same length as the plain text data.\nThe two streams of data are combined using the XOR operation. To recover the\noriginal data, the cypher data is again combined with the random data with the\nXOR operation. After one use, the random data is never reused.\n\nThis works because the XOR operator exhibits the following identity:\n\n```ruby\n(A ^ B ^ B) == A\n```\nThis is the result of the fact that:\n\n```ruby\n(X ^ X) == 0\n```\nand\n\n```ruby\n(X ^ 0) == X\n```\n\nExcepting \"end run\" code cracking (getting the data before/after encryption or\ngetting a copy of the random data) or incompetence (poor quality or reusing the\nrandom data) this code can be shown to be unbreakable.\n\nIt is also very cumbersome to use. It requires that both parties have access to\nlarge amounts of high quality random data that can only be used once. It\nrequires that random data to be kept secret and that these random data remain\nsynchronized.\n\n#### The Pseudo-Random Shortcut\n\nGiven that large quantities of random data are bothersome to deal with, it was\nonly natural that someone would start taking short-cuts. In this case, the\none-time use random data was replaced by a pseudo-random data generator (PRNG).\nThis transforms the Vernam cypher from unbreakable to laughably weak. Why?\n\n - Any PRNG used in this way, requires an initial seed value. This seed value\nis effectively the key of the cypher. To crack the code, the attacker only\nneeds to compute the seed value.\n - Many messages start with a known sequence of bytes. A header if you will.\nThese known bytes make it possible know what values were generated during the\nencryption process. This in turn allows the internal state of the PRNG to be\nmodeled, greatly reducing the number of seed values that must be tested.\n - Once a sequence of random values is known, it is often easy to determine\nwhat values will follow. At this point, the code is broken.\n\nThe problem with the Vernam cypher is that it only maps input symbols to\noutput symbols. The order of the symbols is not changed. With one-use truly\nrandom data, this is not a problem. Knowledge of a few random values tells\nus nothing about the values to follow. With a PRNG, they tell us a very great\ndeal.\n\n#### The Scrambled Vernam Cypher\n\nTo avoid the problems of the classical Vernam cypher, mystik\u0026oacute; makes one\nsignificant change: The Scrambled Vernam Cypher first performs a PRNG\ncontrolled shuffle on the symbols followed by a mapping of input symbols to\noutput symbols.\n\nTo recover data, the Scrambled Vernam Cypher decryption routine performs an\nanti-mapping of the symbols back to their original values followed by a\ncontrolled anti-shuffle of the data back to its original order.\n\nThis data shuffling denies any would-be attacker knowledge of the order of the\ninput data. Thus even with standard message headers, the content of the\noriginal message is (hopefully) no longer relevant.\n\nIt remains to be seen if this is indeed the case. Comments, ideas,\nobservations, and thoughts are welcomed. See below for contributing.\n\n#### References\n\n- One time pads and the Vernam cypher https://en.wikipedia.org/wiki/One-time_pad\n- Random number generation https://en.wikipedia.org/wiki/Random_number_generation\n- The Mersenne twister  https://en.wikipedia.org/wiki/Mersenne_Twister\n- The Random library http://ruby-doc.org/core-2.2.0/Random.html\n- Testing random number generators https://en.wikipedia.org/wiki/TestU01 and\nhttp://www.iro.umontreal.ca/~simardr/testu01/tu01.html\n- Random key generator http://randomkeygen.com/ The 256 bit WEP keys work especially well.\n\n## Contributing\n\nCreating any encryption system is quite an undertaking. For this reason,\nany input is most welcomed. There are two basic plans by which this can\nbe accomplished.\n\n#### Plan A\n\n1. Fork it ( https://github.com/PeterCamilleri/mystiko/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n#### Plan B\n\nGo to the GitHub repository and raise an issue calling attention to some\naspect that could use some TLC or a suggestion or an idea.\n\n## License\n\nThe gem is available as open source under the terms of the\n[MIT License](./LICENSE.txt).\n\n## Code of Conduct\n\nEveryone interacting in the fully_freeze project’s codebases, issue trackers,\nchat rooms and mailing lists is expected to follow the\n[code of conduct](./CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetercamilleri%2Fmystiko","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetercamilleri%2Fmystiko","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetercamilleri%2Fmystiko/lists"}