Sent in by a reader. OTP encryption, both the methodology and philosophy of use, are things we cover in the Advanced RTO Course. You might wanna get in on that while you can. -NCS
Afternoon Scout,
I didn’t know if you wanted to put the Arduino OTP code up on AP as a post, but I would be OK with that.  Here is the source as inline text (I will also include the two PDF files I put on the old forum as well):
#include <SD.h>                                                // Make sure the compiler knows to add the SD card library
#include <SPI.h>
String header, PADln, nxtchar;                                 // Setup the string variables
String fileOutput, obverse;                                    // More strings…
String PadNumber;                                              // Filename
String BlkLn, Bump;
String BlBlock;
char rndchar;                                                  // random character made from the RNG function
int n = 0;                                                     // Filename increment
int x = 0;
int i = 0;
int alphanum = 0;                                              // random placeholder
int sensorValue = 0;                                           // Total of Sensor Values to Mod of “span”
int modulus = 0;                                               // Random Number Output
int maxchar = 126;                                             // Highest ASCII value in the OTP lines
int minchar = 32;                                              // Lowest ASCII value in the OTP lines
int span = maxchar – minchar;                                  // The difference between the highest and lowest
long linecount = 15;                                           // Number of lines of the PADfile
int chipSelect = 4;                                            // setup the cs output line to the SD card socket
void setup() {                                                 // This is where the setup part of the program starts, the part that only runs once at startup
  Serial.begin(115200);                                        // initialize serial communications at 19200 bps for either PC or LCD deisplay:
  BlBlock = char(177);
  Bump = BlBlock+BlBlock+BlBlock+BlBlock;
  for (int i=minchar; i<=maxchar+8; i++) {                     // For loop to stack the ASCII characters for the header from lowest to highest value
    BlkLn.concat(BlBlock);                                    // Add the next character to the end of the stack
  header = “”;                                                 // Blank the header
  for (int i=minchar; i<=maxchar; i++) {                       // For loop to stack the ASCII characters for the header from lowest to highest value
    header.concat(char(i));                                    // Add the next character to the end of the stack
void loop()  {                                                         // This is the main loop of the program, it just keeps doing all of the next segment over and over
  Serial.println(“Page#:” + PadNumber);
    for (int i=0; i<linecount; i++) {                                  // Count lines of output till “linecount”, and then let it pause for 10 seconds, then start another batch
  RNG();                                                               // Call the RNG function and pull a true random number
  PADln = “”;                                     // Set the variable for the PAD line generation “PADln”
  obverse= “”;
      while (PADln.length() < span+1) {                                  // While the length of PADln is less than the length of the header line, go and do the following…
      RNG();                                                           // Grab another random number
      rndchar = char(modulus);                                         // Convert that random number to a ASCII character so we can check it out
      if (header.indexOf(rndchar)>=0 && PADln.indexOf(rndchar)==-1) {  // IF it is in the header but not in “PADln” yet, add it to the end of “PADln”
        PADln.concat(rndchar);                                         // the actual add it to the end line
      for (int i=0; i<=span; i++) {
        x = PADln.indexOf(header.charAt(i));
    Serial.println(fileOutput);                                          // Send the line out the server
    Serial.println(fileOutput);                                              // Drop the header out to the server
    Serial.println(fileOutput);                                          // Send the line out the server
n++;                                                                   // add one to the filename and keep going
//  Functions from here on down…
void RNG() {
  sensorValue = 0;                                                     // read all the analog values of the 6 analog ports, adding them together in “sensorvalue”
  sensorValue = analogRead(0) + analogRead(1) + analogRead(2) + analogRead(3) + analogRead(4) + analogRead(5);
  modulus = minchar + sensorValue % (span+1);                          // take the remainder of the total into “span+1” and add it to the minimum ASCII value to get
                                                                       // random numbers that are in a tighter range and work quicker through the system
  // delay(1);                                                         // (REMMED OUT) delay at least a millisecond between RNG reads so that the ADCs have a chance to settle
 Save as PDF

Welcome American Partisans!

Sign up to receive articles daily

We don’t spam! Read our privacy policy for more info.

Liked it? Take a second to support us on Patreon!