Caesar Cipher Hints

Try out this example project and consider how you might design your own. Here is an example algorithm for the shift cipher. Do it your way.

  1. Create and initialize (set to blank) three variables to store inputText, shiftValue, and outputText.
  2. Plaintext (or cleartext) is normal unencrypted text.
  3. Ask the user to enter a plaintext message to be encoded. Set the inputText variable to the answer from the user.
  4. Ask the user to enter a shift value for the shift cipher. If their answer is a number:
    • Set the shiftValue variable to their answer.
    • Ask the user if they wish to encode or decode.
    • Then call a custom procedure to encrypt or decrypt the data. Here is an example encode algorithm. You could:
      • Use it and write a decode reporter block on your own.
      • Modify this into a encode/decode block that uses negative shift values to decode.
      • Or create your own custom procedure and ignore the example.
      Encode(text)(shift #){script variable(encodedText); set(encodedText) to (); for(i)=(1) to (length of (text)){set(encodedText) to (join(encodedText)(Encode One Character(lette..}; report(encodedText}
      Notice that Encode reporter relies on a simpler reporter, Encode One Character, that encodes a single character by shifting it a given amount. This abstraction makes the code easier to manage.
  5. Here are enough blocks to build Encode One Character:
    Encode One Character (char) (shift#){report()}; unicode of(char); ()+(shift); unicode of () as letter
  6. Check that your code works as expected.