Introduction: How to Read Encrypted Books and Encrypt Strings Using Custom Key on Midbar (Teensy 4.1) V3.0
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:
- Open the Serial Terminal (because the book encryption key is printed to it);
- Select the "Other Options" line in the main menu;
- Press the "Enter" key on the USB keyboard;
- Select the "Read Encrypted Book" line in the main menu;
- Press the "Enter" key on the USB keyboard;
- Select the "Print Encryption Key" line in the main menu;
- 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:
- 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;
- Click on "File" and then select "Encrypt Book;"
- Paste the encryption key to the textbox in the pop-up entry;
- Press the "OK" button;
- Navigate to the folder where the book you want to encrypt is located, select the book, and then press the "Open" button;
- Wait for the encryption process to complete;
- 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:
- Select the "Other Options" line in the main menu;
- Press the "Enter" key on the USB keyboard;
- Select the "Read Encrypted Book" line in the main menu;
- Press the "Enter" key on the USB keyboard;
- Select the "Read Book" line in the main menu;
- Press the "Enter" key on the USB keyboard;
- Select the book you'd like to read by pressing the "←" (Leftwards Arrow) and "→" (Rightwards Arrow) keys on the USB keyboard;
- Press the "Enter" key on the USB keyboard;
- 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:
- Open the Serial Terminal (because the ciphertext is printed to it);
- Select the "Other Options" line in the main menu;
- Press the "Enter" key on the USB keyboard;
- Select the "Custom Key Encryption" line in the main menu;
- Press the "Enter" key on the USB keyboard;
- Select the "Encrypt String" line;
- Choose the input source;
- Press the "Enter" key on the USB keyboard;
- Enter the key on the USB keyboard;
- Press the "Enter" key on the USB keyboard;
- 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;
- 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:
- Open the Serial Terminal (because you'll need to paste the ciphertext to it);
- Select the "Other Options" line in the main menu;
- Press the "Enter" key on the USB keyboard;
- Select the "Custom Key Encryption" line in the main menu;
- Press the "Enter" key on the USB keyboard;
- Select the "Decrypt String" line;
- Choose where to display the decrypted string;
- Press the "Enter" key on the USB keyboard;
- Enter the key on the USB keyboard;
- Press the "Enter" key on the USB keyboard;
- Paste the ciphertext to the Serial Terminal;
- Press the "Send" button in the Serial Terminal.