[{"element_type":"user_image","content":"https://cdn-learn.adafruit.com/user_assets/assets/000/001/941/original/Screenshot_from_2025-07-29_21-04-09.png?1753841119","metadata":{}},{"element_type":"text","content":"\n  \n        \u003cp\u003eHistorically it's been common for militaries to use purpose built mechanical cipher machines like the well known \u003ca href=\"https://en.wikipedia.org/wiki/Enigma_machine\"\u003eEnigma Machine\u003c/a\u003e, or the more mundanely named \u003ca href=\"https://en.wikipedia.org/wiki/M-209\"\u003eM-209\u003c/a\u003e. Ever since I learned about these devices they fascinated me. This project is a small toy cipher device inspired by them albeit made with a microcontroller instead of mechanical parts and pieces.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eI showed this project on Show \u0026amp; Tell, the video is embedded below.\u003c/p\u003e\n      \n","metadata":{}},{"element_type":"embed","content":"https://www.youtube.com/live/Oh0MrIUNicU?si=9il0EbCbylVEqyba\u0026t=810"},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003ch2\u003eHardware\u003c/h2\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"product","content":"https://www.adafruit.com/product/5723","metadata":{}},{"element_type":"product","content":"https://www.adafruit.com/product/2890","metadata":{}},{"element_type":"product","content":"https://www.adafruit.com/product/3127","metadata":{}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003ch2\u003eGenerate Keys\u003c/h2\u003e\n\u003cp\u003eBy default device expects to find a set of keys in the file\u0026nbsp;\u003cstrong\u003efizzbuzz.keys\u003c/strong\u003e in the root of the \u003cstrong\u003eCIRCUITPY\u003c/strong\u003e drive. It should be a text file with 4 lines in it. The key file can be generated with the following script included in the project repo.\u0026nbsp;\u003c/p\u003e\n\u003cp\u003eRun this script and save then copy the resulting \u003cstrong\u003efizzbuzz.keys\u003c/strong\u003e file to your \u003cstrong\u003eCIRCUITPY\u003c/strong\u003e drive.\u003c/p\u003e\n\u003cp\u003eHere is an example of what the key file should look like:\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"code","content":"[!;VZjqy,kPgfD.\u003e0eFXK=C7A|~tE)xn+*:SWuNa5b#9UH`3c? r4Y1\u0026d\"]-Q\\Mm$i8^2o6%'JzhlsT@_}(\u003cp{vLGI/wROB\nq5v@:6SA'Lwch%-#p\u003cCYt8.)3 ]yT^meGk;VR0HB$K9}I=WF(Of/nugs\\iJar{XxZNodP?_\u003e,*+7[DM|E~\u0026!Uz124`\"ljbQ\n06*^H8N1:\u0026/\\hypP m`f'bn3DG,XJ{_jM=o-c\u003eTuYr;IC[Q]S#$%\u003cZsFwaxzW+vEt9i@|e(2kKBAq!4LU~}.dg7)5?lV\"RO\n\\lE\u003cPj5|MQK?.nma!-,yNU*:TG\" JoW6F(%92^~8$xvO0e\u003e#krH]h+='\u0026A[7V@u1_LX3ct){zZYp`BIgR/4sd}b;qCSfwiD","metadata":{"language":"auto","linenums":false}},{"element_type":"text","content":"\n  \n  \n        \u003cp\u003e\u003cstrong\u003efizzbuzz_cipher_keygen.py\u003c/strong\u003e\u003c/p\u003e\n      \n\n","metadata":{}},{"element_type":"embed","content":"https://github.com/FoamyGuy/USB_Cipher_Machine/blob/main/fizzbuzz_cipher_keygen.py"},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003ch2\u003eOperation\u003c/h2\u003e\n\u003cp\u003eThe device has two modes encrypting, and decrypting, each has their own behavior outlined here. To change modes the user can press the boot button on the Feather.\u003c/p\u003e\n\u003ch3\u003eEncrypting\u003c/h3\u003e\n\u003cp\u003eIn encrypting mode input is read from USB Host. The user connects a standard USB HID keyboard to the USB A Host port on the Feather. The user types the cleartext message that they want to encrypt into the keyboard. As they type the feather sends the ciphertext out over the standard USB connection via HID to be typed into the computer or other device that the Feather is plugged in to.\u003c/p\u003e\n\u003ch3\u003eDecrypting\u003c/h3\u003e\n\u003cp\u003eIn decrypting mode input is still read from the connected keyboard over USB Host. However for decrypting the user will type in the cipher text value to the keyboard. The cleartext output will appear on the 14 segment displays connected to the feather. Cleartext is not sent to the computer, it is shown only on the 14 segment display module.\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"text","content":"\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n        \u003ch2\u003eCode\u003c/h2\u003e\n\u003cp\u003eThe \u003cstrong\u003ecode.py\u003c/strong\u003e for this project is embedded below. To get the code bundled together with required libraries click the Download Project Bundle button.\u003c/p\u003e\n      \n\n\n\n\n\n\n\n\n\n\n\n\n","metadata":{}},{"element_type":"button","content":"https://github.com/FoamyGuy/USB_Cipher_Machine/releases/download/0.1.1/USB_Cipher_Machine-9234e84.zip","metadata":{"class":"btn btn-large btn-block btn-primary","button_type":"primary","target":"_blank","zip_folder":"false"}},{"element_type":"embed","content":"https://github.com/FoamyGuy/USB_Cipher_Machine/blob/main/code.py"},{"element_type":"text","content":"\n  \n  \n  \n  \n        \u003ch2\u003eFizzBuzz Cipher Algorithm\u003c/h2\u003e\n\u003cp\u003eThe encryption algorithm that the device uses is a custom cipher that I created while tinkering, I call it the FizzBuzz Cipher. It is similar to the Enigma cipher in that it is a \u003ca href=\"https://en.wikipedia.org/wiki/Polyalphabetic_cipher\"\u003epolyalphabetic substitution cipher\u003c/a\u003e. Like enigma it sends the input text through a series of substitutions, and after each input letter a manipulation is made to the mechanism that determines the substitution for the next letter. With enigma that manipulation is the rotor(s) turning after each key press. In the FizzBizz cipher the substitutions work similarly to the enigma rotors, though the \"rotor\" is laid out in a straight line inside the key file. To find the ciphertext for a cleartext character the following steps are used:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eFind the cleartext character in the first line of of the key file.\u003c/li\u003e\n\u003cli\u003eFind character at the same index in the next line down of the key file. This will be the input character for the next step\u003c/li\u003e\n\u003cli\u003eFind the character from the previous step in the 3rd line of the key file\u003c/li\u003e\n\u003cli\u003eFind the character at the same index in the 4th and final line of the key file. This is the final ciphertext output character.\u0026nbsp;\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eSo the cleartext input goes through two substitutions that are ultimately based the relative indexes of the characters within the 4 lines of the key file.\u003c/p\u003e\n\u003cp\u003eThe lines in the key file are referred to as fizz key, buzz key, fizzbuzz key, and none key from top to bottom. If you are familiar with a certain basic programming exercise you might be familiar with these terms and one of the core bits of logic used by the algorithm.\u003c/p\u003e\n\u003cp\u003eNext is the manipulation that makes the cipher polyalphabetic. This part is much different than the enigma algorithms rotors turning. After each keypress and enciphering the keys are \"shifted\" based on the following rules:\u003c/p\u003e\n\u003cul\u003e\n\u003cli\u003eThe fizz key (1st line) has every character whose index is evenly divisible by 2 taken out, grouped together and placed after the remaining odd indexed characters that were left behind. To visualize this I like to imagine the reverse of a \"perfect shuffle\" of a deck of cards. In a perfect riffle shuffle you split the deck in half, then riffle cards alternating from each half one on top of the other until the deck is completely intermingled. We are doing the reverse to our fizz key. We are splitting the full key into two \"piles\" or halves placing alternating characters from the key into each, and then stacking to two piles one after the other.\u003c/li\u003e\n\u003cli\u003eThe buzz key (2nd line) has every character whose index is evenly divisble by 3 taken out, grouped and placed at the end.\u003c/li\u003e\n\u003cli\u003eThe fizzbuzz key (3rd line) has every character whose index is evenly divisible by both 2 and 3 taken out, grouped and placed at the end.\u003c/li\u003e\n\u003cli\u003eThe none key (4th line) has a different and less complex rule. It simply takes the first character in the key and moves it to the end. In essence \"rotating\" the key much like the rotors on the enigma.\u003c/li\u003e\n\u003c/ul\u003e\n\u003cp\u003eWith these shifts applied the characters within the keys now have a vastly different relative order, so inputting several copies of the same cleartext letter in a row will result in different, garbled looking, ciphertext coming out. Such as \"AAAA\" encoding to \"rhpG\".\u003c/p\u003e\n\u003cp\u003eBy default, using keys generated with the script above the cipher supports all upper and lower case letters, the digits 0-9 and several special characters. Speficially it is every character in ASCII from the space (hex 0x20) to the tilde (hex 0x7E). But the cipher algorithm itself can be used with different keys. The main limitation is that every possible cleartext character must appear exactly once within each of the 4 keys.\u0026nbsp;\u003c/p\u003e\n      \n\n\n\n","metadata":{}}]