Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Cybersecurity: Encryption Intro

Cybersecurity: Encryption Intro

Caesar Cipher in a Function

Why move the Caesar cipher routine to a function? One advantage would be that you can swap it out with other, better encryption functions, or even function/method calls to a module. As an example, in the next activity, you will replace the caesar function with another one called ascii_shift. After the function swap, your project will only need one block changed!

Example project: caesar_cipher_function

  • Enter caesar_cipher_function, then flash it into the micro:bit.

The functionality is identical to the previous example (caesar_terminal_words).

  • Open the terminal, check that local echo is checked, follow the prompts, and verify that the functionality matches the previous project.
  • Take a look at the actual project you have to work with, it’s the parts inside both the start here block and the forever loop. 

See how all that project has to do is use call caesar to encrypt the word?

How It Works

Your project now gets the ciphertext from this one block:

The caesar function has two parameters, key and word. Keep in mind that word could also be ciphertext that you are converting back with a negative key value. Inside the function, it does all the same steps as caesar_terminal_words, and then returns the result.


Printer-friendly version
Apply Caesar Cipher to Words from Terminal
Prev
ASCII and Other Simple Ciphers
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress