Pmw2.0 Englishprojectsize[744 426]turtles-have[]globals[]globals-list[globals-vars] shapesprocedurestext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\froman\fprq2 Times New Roman;}{\f5\fmodern\fprq1 Courier New;}{\f6\fmodern Courier New;}{\f7\fmodern Courier New;}} {\colortbl\red0\green0\blue0;\red128\green0\blue0;\red0\green128\blue0;} \deflang1033\pard\plain\lang3081\f5\fs20\cf2\i =========================\plain\lang3081\f4\fs24\cf2\i \par \plain\lang3081\f5\fs24\cf2\i AFFINE CIPHER SYSTEM \par \plain\lang3081\f5\fs20\cf2\i =========================\plain\lang3081\f4\fs24\cf2\i \par \plain\lang3081\f5\fs18\cf2\i David Dimsey 2005 \par ============================= \par A plaintext message is entered into the "plaintext" box. The sliders are used to set the multiplying factor and the added constant for the affine cipher: \par C = aP + b \par where P is the plaintext and C is the ciphertext. \par Note that an affine cipher with multiplier of 1 is just a simple shift (or "Caesar") cipher, while an affine cipher with shift of 0 is a simple multiplication cipher. \par ============================= \par MicroWorlds Pro v1.07 \par =============================\plain\lang3081\f4\fs18\cf0\i \par \plain\lang3081\f4\fs20\cf0 \par \plain\lang3081\f5\fs20\cf0 to startup \par create_interface \par make "characters [a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] \par make "coprimes [1 3 5 7 9 11 15 17 19 21 23 25] \par make "inverses [1 9 21 15 3 19 7 23 11 5 17 25]\plain\f4\fs20\cf0 \par \plain\f5\fs20\cf0 end \par \par to create_interface \par newbutton "clearbutton [-65 -95][clearall] \par set "clearbutton "size [130 25] \par newtext "text1 [-360 205][300 36] \par settext1 [The Affine Cipher] \par text1, top select bottom \par setfont "Arial \par setfontsize 18 \par settc 19 \par transparent "text1 \par newtext "text2 [10 200][300 36] \par settext2 [Please click the 'exit' button before closing this program] \par text2, top select bottom \par setfont "Arial \par setfontsize 8 \par settc 19 \par transparent "text2 \par newbutton "exitbutton [305 197][exit] \par set "exitbutton "size [50 20] \par newtext "plaintext [-360 160][350 250] \par newtext "ciphertext [10 160][350 250] \par newbutton "clearplainbutton [-280 -120][clear plainbox] \par set "clearplainbutton "size [130 25] \par newbutton "clearcipherbutton [150 -120][clear cipherbox] \par set "clearcipherbutton "size [130 25] \par newbutton "encryptbutton [-280 -150][encrypt plaintext] \par set "encryptbutton "size [130 40] \par newbutton "decryptbutton [150 -150][decrypt ciphertext] \par set "decryptbutton "size [130 40] \par newslider "shift [-125 -150][0 25 0] \par newslider "multiplier [10 -150][1 26 1] \par setbg 40 \par end \par \par to exit \par remove "clearbutton \par remove "text1 \par remove "plaintext \par remove "ciphertext \par remove "clearcipherbutton \par remove "clearplainbutton \par remove "encryptbutton \par remove "decryptbutton \par remove "text2 \par remove "shift \par remove "multiplier \par remove "exitbutton \par end \par \par \plain\lang3081\f5\fs20\cf0 to encrypt :plaintext \par if not member? multiplier :coprimes [announce [Not a valid multiplier] setmultiplier 1 stop] \par make "ptext caps checktext :plaintext \par make "ctext "\plain\f4\fs20\cf0 \par \plain\lang3081\f5\fs20\cf0 encrypt1 :ptext \par setciphertext fives :ctext \par ciphertext\plain\f5\fs20\cf0 , \plain\lang3081\f5\fs20\cf0 top select bottom \par \plain\f5\fs20\cf0 setfont "|Courier New|\plain\lang3081\f5\fs20\cf0 setstyle "regular \par top \par end \par \par to encrypt1 :ptext \par if empty? :ptext [stop] \par make "ctext word :ctext \plain\f5\fs20\cf0 char sum mod sum product \plain\lang3081\f5\fs20\cf0 difference ascii first :ptext 65\plain\f5\fs20\cf0 multiplier shift 26 \plain\lang3081\f5\fs20\cf0 65\plain\f4\fs20\cf0 \par \plain\lang3081\f5\fs20\cf0 encrypt1 bf :ptext \par end \par \par to decrypt :ciphertext \par make "ctext lower checktext :ciphertext \par make "ptext " \par findpos multiplier :coprimes \par make "mult item :spot :inverses \par decrypt1 :ctext \par setplaintext :ptext \par plaintext, top select bottom \par \plain\f5\fs20\cf0 setfont "|Courier New|\plain\lang3081\f5\fs20\cf0 setstyle "regular \par top \par end \par \par to decrypt1 :ctext \par if empty? :ctext [stop] \par make "current difference ascii first :ctext 97 \par make "ptext word :ptext char sum mod product difference :current shift :mult 26 97 \par decrypt1 bf :ctext \par end \par \plain\f4\fs20\cf0 \par \plain\f5\fs20\cf0 to clear :boxname \par \plain\lang3081\f5\fs20\cf0 if equal? :boxname "cipherbox [setciphertext "] \par if equal? :boxname "\plain\f5\fs20\cf0 plain\plain\lang3081\f5\fs20\cf0 box [setplaintext "]\plain\f4\fs20\cf0 \par \plain\f5\fs20\cf0 end \par \par \plain\lang3081\f5\fs20\cf0 to findpos :num :list \par if empty? :list [stop] \par make "spot 1 \par findpos1 :num :list \par end \par \par to findpos1 :num :list \par if equal? :num first :list [stop] \par make "spot sum :spot 1 \par findpos1 :num bf :list \par end\plain\f4\fs20\cf0 \par \par \plain\lang3081\f5\fs20\cf0 to cipherbox \par op "cipherbox \par end \par \par to \plain\f5\fs20\cf0 plain\plain\lang3081\f5\fs20\cf0 box \par op "\plain\f5\fs20\cf0 plain\plain\lang3081\f5\fs20\cf0 box \par end \par \par to clearall \par setplaintext " \par setciphertext " \par end \par \plain\lang3081\f4\fs20\cf2 \par \plain\f5\fs20\cf0 to checktext :intext \par if empty? :intext [op " ] \par if member? first :intext :characters \par \tab [op word first :intext checktext bf :intext ] \par checktext bf :intext \par end \par \par to lower :\plain\lang3081\f5\fs20\cf0 inword \par \plain\f5\fs20\cf0 if equal? :inword " [op " ] \par if\plain\lang3081\f5\fs20\cf0 else\plain\f5\fs20\cf0 (ascii \plain\lang3081\f5\fs20\cf0 first \plain\f5\fs20\cf0 :\plain\lang3081\f5\fs20\cf0 inword\plain\f5\fs20\cf0 ) \plain\lang3081\f5\fs20\cf0 > 96\plain\f5\fs20\cf0 \par \plain\lang3081\f4\fs20\cf0 \tab \plain\f5\fs20\cf0 [op \plain\lang3081\f5\fs20\cf0 word first \plain\f5\fs20\cf0 :\plain\lang3081\f5\fs20\cf0 inword lower bf :inword\plain\f5\fs20\cf0 ] \par [op word char ((ascii first :inword) \plain\lang3081\f5\fs20\cf0 +\plain\f5\fs20\cf0 32) \plain\lang3081\f5\fs20\cf0 lower\plain\f5\fs20\cf0 bf :inword] \par end \par \par to caps :inword \par if equal? :inword " [op " ] \par ifelse (ascii first :inword) > 96 \par \tab [op word char ((ascii first :inword) - 32) caps bf :inword] \par \tab [op word first :inword caps bf :inword] \par end \par \par to fives :inword \par if (count :inword) < 5 [op :inword] \par op se word first :inword word first bf :inword word first bf bf :inword word first bf bf bf :inword first bf bf bf bf :inword \par fives bf bf bf bf bf :inword \par end \par \par to mod :a :b \par \plain\lang3081\f5\fs20\cf0 if :a > 0 [op remainder :a :b]\plain\f4\fs20\cf0 \par \plain\f5\fs20\cf0 op \plain\lang3081\f5\fs20\cf0 mod\plain\f5\fs20\cf0 \plain\lang3081\f5\fs20\cf0 sum \plain\f5\fs20\cf0 :a\plain\lang3081\f5\fs20\cf0 :b\plain\f5\fs20\cf0 :b \par end \par \plain\f7\fs20\cf0 \par } 3pagenamepage1curturtlet1curtextplaintexttransition0Dturtle-deamons[[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []]Cmouse-deamons[[] [] [] [] [] [] [] [] [] [] [] [] [] [] [] []] bg40$buffer$$6HZl~ 2DVhz .@Rdv*<N`r&8J\n"4FXj| 0BTfx,>Pbt(:L^p  $ 6 H Z l ~  2 D V h z  . @ R d v   * < N ` r   & 8 J \ n "4FXj| 0BTfx,>Pbt(:L^p$6HZl~ 2DVhz .@Rdv*<N`r&8J\n"4FXj| 0BTfx,>Pbt(:L^p$6HZl~ 2DVhz .@Rdvobject typet namet1locked?false xpos372 ypos213 shape0penstate0 size40pencolor0 heading0 pensize1shown?true fcn[] kind1shapeinturtlehave-list[has] colorin9objecttypebuttonnameclearbuttonrect[307 308 130 25]show-name?falselocked?falsefcn[clearall] kind1'object typetextnametext1rect[12 8 300 36]show-name?truelocked?falsevisible?truesnaped?truetext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\froman\fprq2 Times New Roman;}{\f5\fmodern\fprq1 Courier New;}{\f6\fmodern Courier New;}{\f7\fmodern Courier New;}} {\colortbl\red0\green0\blue0;\red128\green0\blue0;\red0\green128\blue0;} \deflang1033\pard\plain\f3\fs36\cf1 The Affine Cipher\plain\f3\fs20 \par } Robject typetextnametext2rect[382 13 300 36]show-name?truelocked?falsevisible?truesnaped?truetext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\froman\fprq2 Times New Roman;}{\f5\fmodern\fprq1 Courier New;}{\f6\fmodern Courier New;}{\f7\fmodern Courier New;}} {\colortbl\red0\green0\blue0;\red128\green0\blue0;\red0\green128\blue0;} \deflang1033\pard\plain\f3\fs16\cf1 Please click the 'exit' button before closing this program\plain\f3\fs20 \par } objecttypebuttonnameexitbuttonrect[677 16 50 20]show-name?falselocked?falsefcn[exit] kind1 object typetextnameplaintextrect[12 53 350 250]show-name?truelocked?falsevisible?truesnaped?falsetext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\froman\fprq2 Times New Roman;}{\f5\fmodern\fprq1 Courier New;}{\f6\fmodern Courier New;}{\f7\fmodern Courier New;}} {\colortbl\red0\green0\blue0;\red128\green0\blue0;\red0\green128\blue0;} \deflang1033\pard\plain\f3\fs20 \par } object typetextnameciphertextrect[382 53 350 250]show-name?truelocked?falsevisible?truesnaped?falsetext{\rtf1\ansi\deff0\deftab720{\fonttbl{\f0\fswiss MS Sans Serif;}{\f1\froman\fcharset2 Symbol;}{\f2\fswiss\fprq2 System;}{\f3\fswiss Arial;}{\f4\froman\fprq2 Times New Roman;}{\f5\fmodern\fprq1 Courier New;}{\f6\fmodern Courier New;}{\f7\fmodern Courier New;}} {\colortbl\red0\green0\blue0;\red128\green0\blue0;\red0\green128\blue0;} \deflang1033\pard\plain\f3\fs20 \par } objecttypebuttonnameclearplainbuttonrect[92 333 130 25]show-name?falselocked?falsefcn[clear plainbox] kind1objecttypebuttonnameclearcipherbuttonrect[522 333 130 25]show-name?falselocked?falsefcn[clear cipherbox] kind1objecttypebuttonnameencryptbuttonrect[82 363 140 41]show-name?falselocked?falsefcn[encrypt plaintext] kind1objecttypebuttonnamedecryptbuttonrect[522 363 151 40]show-name?falselocked?falsefcn[decrypt ciphertext] kind1objecttypeslidernameshiftrect[247 363 120 18]show-name?truelocked?falsevisible?true min0 max25 current1value| 1|objecttypeslidernamemultiplierrect[382 363 120 18]show-name?truelocked?falsevisible?true min1 max26 current1value| 1|