08-04-10.mw

> with(StringTools):
 

> Alphabet := "abcdefghijklmnopqrstuvwxyz";
Cryptabet:= "THEQUICKBROWNFXJMPSVLAZYDG";
 

 

abcdefghijklmnopqrstuvwxyz
THEQUICKBROWNFXJMPSVLAZYDG (1)
 

> length(Alphabet);
 

26 (2)
 

> length(Cryptabet);
 

26 (3)
 

> Scramble := msg -> CharacterMap(Alphabet, Cryptabet, msg);
 

proc (msg) options operator, arrow; StringTools:-CharacterMap(Alphabet, Cryptabet, msg) end proc (4)
 

> Scramble("eggs");
 

UCCS (5)
 

> Unscramble:= cipher -> CharacterMap(Cryptabet, Alphabet,  cipher);
 

proc (cipher) options operator, arrow; StringTools:-CharacterMap(Cryptabet, Alphabet, cipher) end proc (6)
 

> Unscramble("UCCS");
 

eggs (7)
 

> Scramble("Do not read this.");
 

DX FXV PUTQ VKBS. (8)
 

> Unscramble(%);
 

yo not read this. (9)
 

> Ascii("d");
 

Ascii( (10)
 

> convert("d",bytes);
 

[100] (11)
 

> nums:=convert("Yo' mommy so fat that...", bytes);
 

[89, 111, 39, 32, 109, 111, 109, 109, 121, 32, 115, 111, 32, 102, 97, 116, 32, 116, 104, 97, 116, 46, 46, 46] (12)
 

> crypt:=[seq(nums[i]+3,i=1..nops(nums))];
 

[92, 114, 42, 35, 112, 114, 112, 112, 124, 35, 118, 114, 35, 105, 100, 119, 35, 119, 107, 100, 119, 49, 49, 49] (13)
 

> crypttext:=convert(crypt,bytes);
 

\r*#prpp|#vr#idw#wkdw111 (14)
 

> Caesar := proc(plain, shift)
  local numlist;
  numlist:=convert(plain, bytes);
   convert( [seq(numlist[i]+shift, i=1..nops(numlist))], bytes);
end:
 

> noise:=Caesar("Yo' mommy so fat that...",3);
 

\r*#prpp|#vr#idw#wkdw111 (15)
 

> Caesar(noise,-3);
 

Yo' mommy so fat that... (16)
 

> Caesar("Yo' mommy so fat that...",50);
 

ııYRıııııRııRıııRıııı (17)
 

> Caesar("Yo' mommy so fat that...",128);
 

ıàıııııııııııııı (18)
 

> Caesar := proc(plain, shift)
  local numlist;
  numlist:=convert(plain, bytes);
   convert( [ seq(modp(numlist[i]+shift, 128), i=1..nops(numlist))], bytes);
end:
 

> 27 mod 5;
 

2 (19)
 

> modp(27,5);
 

2 (20)
 

> Caesar("Yo' mommy so fat that...",3);
 

\r*#prpp|#vr#idw#wkdw111 (21)
 

> Caesar("Yo' mommy so fat that...",2003);
 

,Bzs@B@@LsFBs94GsG;4G (22)
 

> Caesar(%,-2003);
 

Yo' mommy so fat that... (23)
 

> Caesar("Yo' mommy so fat that...",-89);
 

(24)
 

> 128-89;
 

39 (25)
 

> Caesar("Yo' mommy so fat that...",39);
 

(26)
 

> Caesar("Yo' mommy so fat that...",-32);
 

9O (27)
 

>