Introduction: How to Read Encrypted Books and Encrypt Strings Using Custom Key on Midbar (Teensy 4.1) V3.0

About: Hi, my name is Max. I'm a Computer Science student. I like making convenient devices. I know that nothing is perfect, but some things are far better than the others, for that reason I'm providing all of my pro…

This tutorial is an accessory to the "DIY Hardware Data Vault With Teensy 4.1 (Midbar (Teensy 4.1) V3.0)"

Before reading this tutorial, ensure that you've completed the aforementioned tutorial at least to step 15.

Supplies

Step 1: Encryption Algorithm

Both books and plaintexts encrypted with the custom key are passed through the Serpent in the CBC mode encryption algorithm.

The only difference between the books and the plaintexts encrypted with the custom key is that the encryption algorithm also attaches the 32-bit tag in front of a plaintext before passing it to the encryption algorithm.

Step 2: Get Encryption Key

Before you can encrypt a book you need to get an encryption key. To do so:

  1. Open the Serial Terminal (because the book encryption key is printed to it);
  2. Select the "Other Options" line in the main menu;
  3. Press the "Enter" key on the USB keyboard;
  4. Select the "Read Encrypted Book" line in the main menu;
  5. Press the "Enter" key on the USB keyboard;
  6. Select the "Print Encryption Key" line in the main menu;
  7. Press the "Enter" key on the USB keyboard.

Step 3: Get the Book in the Text Format

Find a book you want to encrypt to begin with. There are several websites where you can find it, such as Project Gutenberg (note that this is not a promotion for the website, I just find it to be a convenient option). Next, you will need to obtain the book in either UTF-8 or ASCII encoding. Once you have done that, simply copy the entire text of the book (use Ctrl + A for this) and paste it into a new text document (use Ctrl + V). Name the file however you want and save it.

Step 4: Encrypt the Book

To encrypt a book:

  1. Launch the "Book Encrypter For Midbar Teensy 4.1 V3.0.exe" executable file from the "Teensy 4.1 Version\V3.0\Book Encrypter For Midbar Teensy 4.1 V3.0\Book Encrypter For Midbar Teensy 4.1 V3.0\bin\Debug\net6.0-windows" folder;
  2. Click on "File" and then select "Encrypt Book;"
  3. Paste the encryption key to the textbox in the pop-up entry;
  4. Press the "OK" button;
  5. Navigate to the folder where the book you want to encrypt is located, select the book, and then press the "Open" button;
  6. Wait for the encryption process to complete;
  7. In the pop-up window, choose where to save the encrypted book, and press the "Save" button to actually save it.

Step 5: Move the Encrypted Book to the SD Card

Now move the encrypted book(s) to the "books" folder on an SD card.

Make sure that the SD card is formatted to the "FAT32" file system!

Step 6: Read Encrypted Book

To read an encrypted book:

  1. Select the "Other Options" line in the main menu;
  2. Press the "Enter" key on the USB keyboard;
  3. Select the "Read Encrypted Book" line in the main menu;
  4. Press the "Enter" key on the USB keyboard;
  5. Select the "Read Book" line in the main menu;
  6. Press the "Enter" key on the USB keyboard;
  7. Select the book you'd like to read by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
  8. Press the "Enter" key on the USB keyboard;
  9. Press the "Esc" key on the USB keyboard to close the book and return to the main menu, press any other key on the USB keyboard to get to the next page.

Step 7: Encrypt String With Custom Key

To encrypt string with a custom key:

  1. Open the Serial Terminal (because the ciphertext is printed to it);
  2. Select the "Other Options" line in the main menu;
  3. Press the "Enter" key on the USB keyboard;
  4. Select the "Custom Key Encryption" line in the main menu;
  5. Press the "Enter" key on the USB keyboard;
  6. Select the "Encrypt String" line;
  7. Choose the input source;
  8. Press the "Enter" key on the USB keyboard;
  9. Enter the key on the USB keyboard;
  10. Press the "Enter" key on the USB keyboard;
  11. Depending on the chosen input source, either enter the text you'd like to encrypt on the USB keyboard or paste it to the Serial Terminal;
  12. Depending on the chosen input source, either press the "Enter" key on the USB keyboard or press the "Send" button in the Serial Terminal.

Step 8: Decrypt String With Custom Key

To decrypt string with a custom key:

  1. Open the Serial Terminal (because you'll need to paste the ciphertext to it);
  2. Select the "Other Options" line in the main menu;
  3. Press the "Enter" key on the USB keyboard;
  4. Select the "Custom Key Encryption" line in the main menu;
  5. Press the "Enter" key on the USB keyboard;
  6. Select the "Decrypt String" line;
  7. Choose where to display the decrypted string;
  8. Press the "Enter" key on the USB keyboard;
  9. Enter the key on the USB keyboard;
  10. Press the "Enter" key on the USB keyboard;
  11. Paste the ciphertext to the Serial Terminal;
  12. Press the "Send" button in the Serial Terminal.