Skip to content
UoL CS Notes

Lecture 10-1

COMP105 Lectures

The Caesar Cipher

The Caesar Cipher is a shift method of encoding. This shifts every letter forward by three and wraps around when z is reached.

There is no particular reason to shift by three and you can shift by any number between zero and 25. Shifting by 13 would be a ROT13.

Working with Characters

The Data.Char package has some useful functions for working with characters.

  • The ord function takes a character and returns its ASCII value.
  • The chr function turns an ASCII value into a character.

To import a package use the line:

import ...

using the name of the package you want to import.

Implementation

View the slides and the source code to find the implementation of the Caesar Shift functions.