{VERSION 5 0 "SUN SPARC SOLARIS" "5.0" } {USTYLETAB {CSTYLE "Maple Input" -1 0 "Courier" 0 1 255 0 0 1 0 1 0 0 1 0 0 0 0 1 }{CSTYLE "2D Math" -1 2 "Times" 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 1 }{CSTYLE "2D Output" 2 20 "" 0 1 0 0 255 1 0 0 0 0 0 0 0 0 0 1 } {PSTYLE "Normal" -1 0 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Text Output" -1 2 1 {CSTYLE "" -1 -1 "Courier" 1 10 0 0 255 1 0 0 0 0 0 1 3 0 3 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "Warning" 2 7 1 {CSTYLE "" -1 -1 " " 0 1 0 0 255 1 0 0 0 0 0 0 1 0 0 0 }0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 } {PSTYLE "Maple Output" 0 11 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }3 3 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }{PSTYLE "" 11 12 1 {CSTYLE "" -1 -1 "" 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 }1 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 }} {SECT 0 {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }}{PARA 0 "> " 0 " " {MPLTEXT 1 0 18 "with(StringTools):" }}{PARA 7 "" 1 "" {TEXT -1 58 " Warning, the assigned name Group now has a global binding\n" }}} {EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 68 "A:=cat(\"\\n\\t\",Select(IsP rintable,convert([seq(i,i=1..225)],bytes)));" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%\"AGQ\\q|+|*~!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFG HIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz|fr|gr|hr|ir6\"" } }}{EXCHG {PARA 0 "" 0 "" {TEXT -1 40 "This procedures are taken from c lass 14." }}{PARA 0 "" 0 "" {TEXT -1 1 " " }{MPLTEXT 1 0 0 "" }}{PARA 0 "> " 0 "" {MPLTEXT 1 0 89 "StringtoList:=proc(x)\nlocal i;\nglobal A ;\n[seq(SearchText(x[i],A)-1,i=1..length(x))];\nend:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 79 "ListtoString:=proc(y)\nlocal i;\nglobal A ;\ncat(seq(A[y[i]+1],i=1..nops(y)));\nend:" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 116 "StringToKgraph:=proc(x::string,k::posint)\nlocal p ;\nglobal A;\np:=length(A);\nconvert(StringtoList(x),base,p,p^k);\nend ;" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%/StringToKgraphGf*6$'%\"xG%'str ingG'%\"kG%'posintG6#%\"pG6\"F/C$>8$-%'lengthG6#%\"AG-%(convertG6&-%-S tringtoListG6#9$%%baseGF2)F29%F/F5F/" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 43 "l:=StringToKgraph(\"To be or not to be\", 3);" }} {PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"lG7(\"&Hn#\"&td#\"&Zq#\"'6r\")\"'t /x\"'PYn" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 126 "KgraphToString :=proc(x::list(nonnegint), k::posint)\nlocal p;\nglobal A;\np:=length( A);\nListtoString(convert(x,base,p^k,p));\nend;" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%/KgraphToStringGf*6$'%\"xG-%%listG6#%*nonnegintG'%\"k G%'posintG6#%\"pG6\"F2C$>8$-%'lengthG6#%\"AG-%-ListtoStringG6#-%(conve rtG6&9$%%baseG)F59%F5F2F8F2" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "KgraphToString(l,3);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#Q3To~be~or ~not~to~be6\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 513 "randomize (): \n RSAsetup:=proc(numdigits::posint)\n local p,q,phi,e,n, x, pm , qm; \n\n if (numdigits <= 4) then \n error(\"Too few digits for this to work\"); \n fi; \n\n pm:=floor((numdigits-1)/2); \n q m:=numdigits-pm; \n p:=nextprime(rand(10^(pm-1)..10^(pm))()); \n \+ q:=nextprime(rand(10^(qm-1)..10^(qm))()); \n\n n:=p*q; \n phi:=( p-1)*(q-1); \n\n e:=rand(3..phi/2)(); \n while(gcd(e,phi) <> 1) d o \n e:=rand(3..phi/2)(); \n od; \n x := modp(1/e, phi); \+ \n return([[n,e],[n,x]]); \n end:" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 106 "RSAEncodeNum := proc(num::nonnegint, key::list(posin t))\n return( modp( num &^ key[2], key[1] ));\n end;" }}{PARA 12 " " 1 "" {XPPMATH 20 "6#>%-RSAEncodeNumGf*6$'%$numG%*nonnegintG'%$keyG-% %listG6#%'posintG6\"F0F0O-%%modpG6$-%#&^G6$9$&9%6#\"\"#&F:6#\"\"\"F0F0 F0" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 61 "keys:=RSAsetup(60):\n public := keys[1];\n private:= keys[2];" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%'publicG7$\"gn^)\\1+b7mWVf#=hPYh:wzVHfDZ_[b'*=k\"fnf8 +?0AM6jzDm&z4y#G&)H!3Ac+K^OlHY" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%(p rivateG7$\"gn^)\\1+b7mWVf#=hPYh:wzVHfDZ_[b'*=k\"gnRI@>d#Q=U)ejuJFX7x(y 6#\\XGb+W^3)*e" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 37 "enconum:= RSAEncodeNum(123456,public);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%(enc onumG\"gnW1*4_!G8)>.o1O`6nCX,1/\\Tf'olFD+J" }}}{EXCHG {PARA 0 "> " 0 " " {MPLTEXT 1 0 30 "RSAEncodeNum(enconum,private);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#\"'cM7" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 139 "A lphabet := cat(\"\\n\\t\",Select(IsPrintable,convert([seq(i,i=1..255)] ,bytes))):\n Alen := length(Alphabet);\n k:=floor(log[Alen](public[1 ]));" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%%AlenG\"#(*" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%\"kG\"#I" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 63 "text:=\"Just when I thought I was out... they pull me back in! \";" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#>%%textGQWJust~when~I~thought~I ~was~out...~they~pull~me~back~in!6\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 33 "encotext:=StringToKgraph(text,k);" }}{PARA 12 "" 1 " " {XPPMATH 20 "6#>%)encotextG7$\"fnyBzA^%)>[bSL-Le_zVfpCg[S\"))Rn$\\)p \"PiSc[hJB@TUD7oT]'[s'zu,A!>" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 41 "crypt:=map(RSAEncodeNum,encotext,public);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%&cryptG7$\"gn0skW@!p=(GlVl%p'**>n%43!*)\\$y<;GJH*R\"g n&***oZ?2n))pt6?V\"=%))>C*HE%*G-W$G9wZ>" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 24 "KgraphToString(crypt,k);" }}{PARA 11 "" 1 "" {XPPMATH 20 "6#Qgni:|ir+P~pevTi!h|grE
UB94))M6\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 32 "map(
RSAEncodeNum,crypt,private);" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#7$\"fn
yBzA^%)>[bSL-Le_zVfpCg[S\"))Rn$\\)p\"PiSc[hJB@TUD7oT]'[s'zu,A!>" }}}
{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 20 "KgraphToString(%,k);" }}
{PARA 11 "" 1 "" {XPPMATH 20 "6#QWJust~when~I~thought~I~was~out...~the
y~pull~me~back~in!6\"" }}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 0 "" }
}}{EXCHG {PARA 0 "> " 0 "" {MPLTEXT 1 0 242 "RSAEncodeString := proc(t
ext::string, key::list(posint))\nlocal Alen, k;\n global Alphabet;
\nAlen := length(Alphabet); \nk:=floor(log[Alen](key[1])); \nKgra
phToString( map(RSAEncodeNum, StringToKgraph(text, k), key), k
+1); \nend;" }}{PARA 12 "" 1 "" {XPPMATH 20 "6#>%0RSAEncodeStringGf*
6$'%%textG%'stringG'%$keyG-%%listG6#%'posintG6$%%AlenG%\"kG6\"F3C%>8$-
%'lengthG6#%)AlphabetG>8%-%&floorG6#-&%$logG6#F66#&9%6#\"\"\"-%/Kgraph
ToStringG6$-%$mapG6%%-RSAEncodeNumG-%/StringToKgraphG6$9$F