//Sixth grade shift cipher code - lower case encryption code //for students to attempt to decrypt messages //original setting - 13 (no letter swaps) void setup() { size(800, 400); } //write out the message void draw() { int shift; //TO DO - try different shifts to crack the code shift = 13; background(255); textSize(24); fill(0); text(cipher("jr ner uvqqra", shift), 10, 30); //should read: we are hidden } //shift the characters by the specified amounts //leave spaces as spaces //and two possible letter swaps String cipher(String msg, int shift) { String s = ""; int len = msg.length(); for (int x = 0; x < len; x++) { char Curc = (char)msg.charAt(x); if (Curc != ' ') { char c = (char)(Curc + shift); if (c > 'z') s += (char)(Curc - (26-shift)); else s += (char)(Curc + shift); } else s += (char)(msg.charAt(x)); } return s; }