> | with(StringTools): |
> | Alphabet := "abcdefghijklmnopqrstuvwxyz";
Cryptabet:= "THEQUICKBROWNFXJMPSVLAZYDG"; |
(1) |
> | length(Alphabet); |
(2) |
> | length(Cryptabet); |
(3) |
> | Scramble := msg -> CharacterMap(Alphabet, Cryptabet, msg); |
(4) |
> | Scramble("eggs"); |
(5) |
> | Unscramble:= cipher -> CharacterMap(Cryptabet, Alphabet, cipher); |
(6) |
> | Unscramble("UCCS"); |
(7) |
> | Scramble("Do not read this."); |
(8) |
> | Unscramble(%); |
(9) |
> | Ascii("d"); |
(10) |
> | convert("d",bytes); |
(11) |
> | nums:=convert("Yo' mommy so fat that...", bytes); |
(12) |
> | crypt:=[seq(nums[i]+3,i=1..nops(nums))]; |
(13) |
> | crypttext:=convert(crypt,bytes); |
(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); |
(15) |
> | Caesar(noise,-3); |
(16) |
> | Caesar("Yo' mommy so fat that...",50); |
(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; |
(19) |
> | modp(27,5); |
(20) |
> | Caesar("Yo' mommy so fat that...",3); |
(21) |
> | Caesar("Yo' mommy so fat that...",2003); |
(22) |
> | Caesar(%,-2003); |
(23) |
> | Caesar("Yo' mommy so fat that...",-89); |
(24) |
> | 128-89; |
(25) |
> | Caesar("Yo' mommy so fat that...",39); |
(26) |
> | Caesar("Yo' mommy so fat that...",-32); |
(27) |
> |