ROT 13 is a quite easy and famous ciphering for letters that you most probably studied somewhere in your studies (in fact it’s available in Linux terminal). If you didn’t or you don’t remember, check the page on Wikipedia here.
So, ROT13 begins with reversing the text which luckily has a built-in function in LabVIEW. Next we check for the ASCII code of the character and based on the value we either add or subtract 13 and finally reverse back the text.
To do so we begin with having an input string for the input text and adding a couple of functions, to reverse and to convert to a byte array to get the ASCII code. Next we need a For Loop to process this array of codes. This is shown below:
For processing the code, we will utilize the so-called Case Structure; it’s something like Switch-Case in C++ if you are familiar with this. You get it by right click in Block Diagram window and Structures > Case Structure. Then connect the output of the String To Byte Array block to its input. It will create 2 cases automatically, one of them is 0, aka default, and the other is 1. For our application we need 4 cases beside the default one and also delete the 1 case. To add cases, right click on the Case Structure and select Add Case After and continuously add the cases as shown here:
So, again we either add or subtract 13 based on the case. Cases are illustrated below. Note that to browse the different cases, you only need to click on the small arrows on the top boundary of the Case Structure.
Now are done with calculations, we need to convert back to string and reverse it back. So, we just add a few functions after the For Loop as shown below and we also add our While Loop with stop button and timer for delay as usual.
What about adding an OK button to do the ciphering only when we press that button? Again, we use a Case Structure for that. Note that to make a Case Structure around some blocks you already did, after you click on Case Structure, just click and move around the blocks then release.
Now, it’s time fr trying and playing around! It’s fun time 🙂