<?xml version="1.0" encoding="UTF-8"?>
<Worksheet>
<Version major="11" minor="1"/>
<Label-Scheme value="2" prefix=""/>
<View-Properties presentation="true"><Zoom percentage="150"/></View-Properties>
<MapleNet-Properties warnlevel="3" longdelim="true" plotoptions="" echo="1" errorcursor="false" elisiontermsthreshold="10000" elisiontermsbefore="100" errorbreak="1" prettyprint="3" prompt="&gt; " latexwidth="6.0" useclientjvm="true" ansi="false" screenheight="25" labelwidth="20" plotdevice="inline" typesetting="standard" displayprecision="-1" indentamount="4" elisiondigitsthreshold="10000" quiet="false" plotoutput="terminal" rtablesize="10" preplot="" showassumed="1" plotdriver="openviz" elisiontermsafter="100" labelling="true" postplot="" screenwidth="79" elisiondigitsbefore="100" elisiondigitsafter="100" verboseproc="1" imaginaryunit="I" ShowLabels="true"/>
<Styles><Font name="Heading 4" background="[255,255,255]" bold="false" executable="false" family="Serif" foreground="[0,0,0]" italic="true" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 5" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 1" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Text Output" background="[255,255,255]" bold="false" executable="false" family="Monospaced" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Bullet Item" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Equation Label" background="[255,255,255]" bold="true" executable="false" family="Monospaced" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Author" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Text" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Diagnostic" background="[255,255,255]" bold="false" executable="false" family="Monospaced" foreground="[40,120,40]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Heading 2" background="[255,255,255]" bold="true" executable="false" family="Serif" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="16" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Page Number" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="10" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 3" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Maple Plot" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Normal" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Maple Input" background="[255,255,255]" bold="true" executable="true" family="Monospaced" foreground="[255,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Annotation Title" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="18" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="2D Output" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="2D Inert Output" background="[255,255,255]" bold="false" executable="true" family="Times New Roman" foreground="[144,144,144]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Dictionary Hyperlink" background="[255,255,255]" bold="false" executable="false" family="Serif" foreground="[147,0,15]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="true" placeholder="false"/>
<Font name="Dash Item" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Heading 3" background="[255,255,255]" bold="true" executable="false" family="Serif" foreground="[0,0,0]" italic="true" opaque="false" readonly="false" size="14" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 4" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Maple Output" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="List Item" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="2D Input" background="[255,255,255]" bold="false" executable="true" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Line Printed Output" background="[255,255,255]" bold="false" executable="false" family="Monospaced" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Maple Input Placeholder" background="[255,255,255]" bold="true" executable="true" family="Monospaced" foreground="[200,0,200]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="2D Math" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Error" background="[255,255,255]" bold="false" executable="false" family="Monospaced" foreground="[255,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Warning" background="[255,255,255]" bold="false" executable="false" family="Monospaced" foreground="[0,0,255]" italic="false" opaque="false" readonly="true" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Heading 1" background="[255,255,255]" bold="true" executable="false" family="Serif" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="18" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Annotation Text" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Title" background="[255,255,255]" bold="true" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="18" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Ordered List 2" background="[255,255,255]" bold="false" executable="false" family="Times New Roman" foreground="[0,0,0]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="false" placeholder="false"/>
<Font name="Hyperlink" background="[255,255,255]" bold="false" executable="false" family="Serif" foreground="[0,128,128]" italic="false" opaque="false" readonly="false" size="12" subscript="false" superscript="false" underline="true" placeholder="false"/>
<Layout name="Ordered List 5" alignment="left" bullet="ROMAN" firstindent="0" leftmargin="144" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Heading 4" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Text Output" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="newline" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Ordered List 1" alignment="left" bullet="numeric" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Annotation Title" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="12" spacebelow="12" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Bullet Item" alignment="left" bullet="dot" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Author" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="8" spacebelow="8" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Dash Item" alignment="left" bullet="dash" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Heading 3" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Diagnostic" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="any" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Ordered List 4" alignment="left" bullet="ALPHABETIC" firstindent="0" leftmargin="108" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Maple Output" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.3" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Line Printed Output" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="any" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="List Item" alignment="left" bullet="indent" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Heading 2" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="8" spacebelow="2" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Ordered List 3" alignment="left" bullet="roman" firstindent="0" leftmargin="72" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Error" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Maple Plot" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Warning" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Heading 1" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="8" spacebelow="4" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Title" alignment="centred" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="12" spacebelow="12" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Layout name="Ordered List 2" alignment="left" bullet="alphabetic" firstindent="0" leftmargin="36" rightmargin="0" linespacing="0.0" spaceabove="3" spacebelow="3" linebreak="space" pagebreak-before="false" initial="-1" bulletsuffix=""/>
<Layout name="Normal" alignment="left" bullet="none" firstindent="0" leftmargin="0" rightmargin="0" linespacing="0.0" spaceabove="0" spacebelow="0" linebreak="space" pagebreak-before="false" initial="0" bulletsuffix=""/>
<Pencil-style name="Pencil 3" pen-color="[0,0,0]" pen-height="3.0" pen-width="3.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 1" pen-color="[0,0,0]" pen-height="1.0" pen-width="1.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 5" pen-color="[255,0,0]" pen-height="5.0" pen-width="5.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 2" pen-color="[0,0,255]" pen-height="1.0" pen-width="1.0" pen-opacity="1.0"/>
<Pencil-style name="Pencil 4" pen-color="[0,0,255]" pen-height="3.0" pen-width="3.0" pen-opacity="1.0"/>
<Highlighter-style name="Highlighter 2" pen-color="[255,204,0]" pen-height="14.0" pen-width="14.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 4" pen-color="[0,255,255]" pen-height="32.0" pen-width="32.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 3" pen-color="[51,255,0]" pen-height="24.0" pen-width="24.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 1" pen-color="[255,153,255]" pen-height="12.0" pen-width="8.0" pen-opacity="0.8"/>
<Highlighter-style name="Highlighter 5" pen-color="[255,255,0]" pen-height="48.0" pen-width="48.0" pen-opacity="0.8"/>
</Styles>
<Task-table>
    <Task-category name="&lt;default&gt;">
    </Task-category>
</Task-table>
<Task>
</Task><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L1" drawlabel="true">
<Input>
<Text-field style="Title" layout="Title">RSA demo</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L24" drawlabel="true">
<Input>
<Text-field style="Author" layout="Author"><Font encoding="UTF-8">\302\251</Font>2007 by Mike May, S.J., Saint Louis University - maymk@slu.edu</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L2" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">A fast demo of RSA cryptography-  This worksheet uses components so that the Maple code is hidden.</Text-field>
</Input>
</Group>
<Group view="code" labelreference="L51" drawlabel="true">
<Input>
<Text-field prompt="&gt; " style="Maple Input" layout="Normal"></Text-field>
</Input>
</Group></Presentation-Block>
<Section collapsed="true" MultipleChoiceAnswerIndex="-1" MultipleChoiceRandomizeChoices="false" TrueFalseAnswerIndex="-1" EssayAnswerRows="5" EssayAnswerColumns="60"><Title>
<Text-field style="Heading 1" layout="Heading 1">Setting up RSA</Text-field></Title><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L4" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">Set a size for the primes used in terms of bits.  (The  size must be between 5 and 600 bits.)</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L5" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal"></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L6" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">Size of p1<EC-TextArea id="Textp1size" tooltip="size of p1 in bits" enabled="true" visible="true" visiblecharacterwidth="5" visiblerows="1" contents="511" editable="true" wrapping="true"><MapleCode action="content-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.
s1 := parse(GetProperty(Textp1size,'value')):
if not((type(s1,integer)) and (s1 &gt; 5)) then 
  s1 := 5; end if;
if (s1 &gt; 600) then s1 := 600; end if;
SetProperty(Textp1size,'value',s1);
end use; 
</MapleCode></EC-TextArea> in bits. Size of p2 <EC-TextArea id="Textp2size" tooltip="size of p2 in bits" enabled="true" visible="true" visiblecharacterwidth="5" visiblerows="1" contents="513" editable="true" wrapping="true"><MapleCode action="content-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

s2 := parse(GetProperty(Textp2size,'value')):
if not((type(s1,integer)) and (s2 &gt; 5)) then 
  s2 := 5; end if;
if (s2 &gt; 600) then s1 := 600; end if;
SetProperty(Textp2size,'value',s2);
                    
end use; 
</MapleCode></EC-TextArea> in bits.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L9" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"><EC-Button id="Buttonprimeset" caption="choose primes" tooltip="choose random primes of size s1 and s2" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.
s1 := parse(GetProperty(Textp1size,'value'));
s2 := parse(GetProperty(Textp2size,'value'));
p1 := nextprime(rand(2^s1)());
p2 := nextprime(rand(2^s2)());
SetProperty(Textp1,'value',p1);
SetProperty(Textp2,'value',p2);
n := p1*p2;
n1 := (p1-1)*(p2-1);
SetProperty(Textn, 'value', n);
SetProperty(Textphin, 'value', n1);

end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L12" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">p1 = <EC-TextArea id="Textp1" tooltip="value of p1" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="4" contents="11" editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea>, </Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L52" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">p2 = <EC-TextArea id="Textp2" tooltip="value of p2" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="4" contents="17" editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L26" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">We also want to compute n = p1*p2 and phi(n) = (p1-1)*(p2-1).  If we let Maple choose the primes, that was done by the last button.  If we insert our own primes, the next button computes n and phi(n).</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L53" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal" alignment="centred"><EC-Button id="Buttoncomputen" caption="compute n and phi(n)" tooltip="choose random primes of size s1 and s2" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.
p1 := parse(GetProperty(Textp1,'value'));
p2 := parse(GetProperty(Textp2,'value'));
if (isprime(p1) and isprime(p2)) then
   n := p1*p2;
   n1 := (p1-1)*(p2-1);
else
   n := &quot;Either p1 or p2 is not prime&quot;;
   n1 := n;
end if:
SetProperty(Textn, 'value', n);
SetProperty(Textphin, 'value', n1);

end use; 
</MapleCode></EC-Button>
n = <EC-TextArea id="Textn" tooltip="value of p1*p2" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="6" contents="187" editable="false" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L27" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal" alignment="centred">phi(n) = <EC-TextArea id="Textphin" tooltip="(p1-1)*(p2-1)" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="6" contents="160" editable="false" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L43" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal"></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L54" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">Set the encryption key.  The default is e = 2^16+1 = 65537.  Recall that phi(n) and e should be relatively prime.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L29" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">e = <EC-TextArea id="Texte" tooltip="value of e, default 2^16+1" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="1" contents="17" editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea>.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L30" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">We now want to compute d, the inverse of e mod phi(n).</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L44" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"><EC-Button id="ButtonComputed" caption="Compute d" tooltip="Compute d" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

e := parse(GetProperty(Texte, 'value'));
phin := parse(GetProperty(Textphin, 'value'));
if (igcd(e,phin)=1) then;
  d := (1/e) mod phin;
else;
  d := &quot;Bad choice for e in relation to phi(n), try again&quot;;
end if;
SetProperty(Textd,'value',d);
 


end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L22" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">d = <EC-TextArea id="Textd" tooltip="decode value" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="8" contents="113" editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L32" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal"></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L33" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">We would like to publish n and e, destroy p1 and p2, and keep d a secret.</Text-field>
</Input>
</Group></Presentation-Block>
</Section>
<Section collapsed="true" MultipleChoiceAnswerIndex="-1" MultipleChoiceRandomizeChoices="false" TrueFalseAnswerIndex="-1" EssayAnswerRows="5" EssayAnswerColumns="60"><Title>
<Text-field style="Heading 1" layout="Heading 1">Sending and receiving numerical messages</Text-field></Title><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L35" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">We are ready to send numerical message,  Recall that the message should be less than n.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L37" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">message = <EC-TextArea id="Textmessage" tooltip="numerical message" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="4" contents="5" editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L49" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">The ciphertext is message^e mod n.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L45" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"><EC-Button id="ButtonEncrypt" caption="Encrypt message" tooltip="encrypt" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

m := parse(GetProperty(Textmessage,'value'));
e := parse(GetProperty(Texte,'value'));
n := parse(GetProperty(Textn,'value'));
if ((m&lt;n) and type(m,integer)) then;
  c := Power(m,e) mod n;
else; 
  c := &quot;Bad message, try again&quot;;
end if;

SetProperty(Textciphertext,'value',c);


end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L38" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">ciphertext = <EC-TextArea id="Textciphertext" tooltip="numeric ciphertext" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="7" contents="124" editable="false" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L39" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal"></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L40" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">We can also check deciphering</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L46" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"><EC-Button id="Buttoncopyciphertext" caption="copy ciphertext for deciphering" tooltip="copy ciphertext" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

c := parse(GetProperty(Textciphertext,'value'));
SetProperty(Textdeciphermessage,'value',c);

end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L41" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">deciphermessage=<EC-TextArea id="Textdeciphermessage" tooltip="numeric message to decipher" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="7" contents="124" editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L50" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">The decrypted message is ciphertext^d mod n.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L48" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"><EC-Button id="Buttondecipher" caption="decode cipher message" tooltip="decipher" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

n := parse(GetProperty(Textn,'value'));
d := parse(GetProperty(Textd,'value'));
c := parse(GetProperty(Textdeciphermessage,'value'));
m := Power(c,d) mod n;
SetProperty(Textdecodedmessage,'value',m);


end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L47" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal"></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L42" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">decodedmessage=<EC-TextArea id="Textdecodedmessage" tooltip="decoded message" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="7" contents="5" editable="false" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L3" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal"></Text-field>
</Input>
</Group></Presentation-Block>
</Section>
<Section collapsed="true" MultipleChoiceAnswerIndex="-1" MultipleChoiceRandomizeChoices="false" TrueFalseAnswerIndex="-1" EssayAnswerRows="5" EssayAnswerColumns="60"><Title>
<Text-field style="Heading 1" layout="Heading 1">Sending and receiving ASCII messages</Text-field></Title><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L7" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">We are ready to look at sending and receiving ASCII messages.  for encryption and decryption we need a modulus and an exponent.  These can either be typed in or copied from above.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L13" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal"></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L14" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">modulus = <EC-TextArea id="Textmodulus" tooltip="typically n from above" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="7" contents="15319738946071414745652287806820479722989355652407407332833186240094921695272119192677686954145128626781382504848479624597795631377059416743828675185786444231816423824606992501922479224834636443429070660698185639661278392970353186554078235194339904663187297376409798369926961329130001321427736808657047663053" editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea>   <EC-Button id="Buttoncopyn" caption="copy n into modulus" tooltip="take n from above" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

n := parse(GetProperty(Textn,'value'));
SetProperty(Textmodulus,'value',n);


end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L15" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">exponent = <EC-TextArea id="Textexponent" tooltip="either d or e" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="7" contents="7156006047821600311406586914722909894561440782873002436486600399286293816582470739360087137452810208762355045560927518009861874412101864973661095769755711431562251077069251318244829601035215538521175103378996813126495125759180067397435725225773818830728405297412180939209198216377722957601427564623950738465" editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea>  </Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L55" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"> <EC-Button id="Buttoncopyd" caption="copy d into exponent" tooltip="copy d from above into exponent" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

e := parse(GetProperty(Textd,'value'));
if not(type(e,integer)) then
  e := &quot;bad value&quot;;
end if:
SetProperty(Textexponent,'value',e);

end use; 
</MapleCode></EC-Button>  <EC-Button id="Buttoncopye" caption="copy e into exponent" tooltip="copy e from above into exponent" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

e := parse(GetProperty(Texte,'value'));
if not(type(e, integer)) then
  e := &quot;bad value&quot;;
end if;
SetProperty(Textexponent,'value',e);

end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L56" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L57" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">If we are encrypting, we start with the text of the message.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L8" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">text = <EC-TextArea id="Texttext" tooltip="ASCII message" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="2" contents="This is a test of RSA." editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L58" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"><EC-Button id="Buttontexttonumber" caption="Convert text to number" tooltip="text to number" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

p1 := GetProperty(Texttext,'value');
p2 := convert(p1,bytes);
num := 0:
for count from 1 to nops(p2) do
  num := 256*num + op(count,p2);
end do:
SetProperty(Textnumber,'value',num);


end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L59" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">If we are encrypting, we convert the text to a number, copy e into the exponent, and encrypt.  In doing the conversion we consider the ASCII message as a number base 256, with characters representing their numerical equivalent in ASCII.  Thus &quot;a&quot; converts to 97, &quot;b&quot; to 98, &quot;A&quot; to 65, &quot;B&quot; to 66, and so on.  &quot;abc&quot; converts to 97*256^2+98*256^1+99*256^0.  </Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L60" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">If we are decrypting, we copy the encrypted number, copy d into the exponent, and decrypt.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L61" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">number = <EC-TextArea id="Textnumber" tooltip="The message as a number" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="4" contents="31580729390886260418402933847506230651966415598469422" editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L25" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"><EC-Button id="Buttonexponentiate" caption="raise number to exponent" tooltip="raise numer to exponent mod n" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.
num := parse(GetProperty(Textnumber,'value'));
exponent :=  parse(GetProperty(Textexponent,'value'));
modulus :=  parse(GetProperty(Textmodulus,'value'));

if (type(num,integer)) then
  if (num &lt; modulus) then
    num2 := Power(num, exponent) mod modulus;
  else num2 := &quot;error, number too big for modulus&quot;;
  end if:
else num2 := &quot;error, number must be an integer.&quot;;
end if:

(SetProperty(Textnumber2,'value', num2));

end use; 
</MapleCode></EC-Button><EC-Button id="Buttoncopyd2" caption="copy d into exponent" tooltip="copy d from above into exponent" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

e := parse(GetProperty(Textd,'value'));
if not(type(e,integer)) then
  e := &quot;bad value&quot;;
end if:
SetProperty(Textexponent,'value',e);

end use; 
</MapleCode></EC-Button>  <EC-Button id="Buttoncopye2" caption="copy e into exponent" tooltip="copy e from above into exponent" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

e := parse(GetProperty(Texte,'value'));
if not(type(e, integer)) then
  e := &quot;bad value&quot;;
end if;
SetProperty(Textexponent,'value',e);

end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L62" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">number2 = <EC-TextArea id="Textnumber2" tooltip="Number to exponent" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="6" contents="13462843292938075384270145465565296618755919531927648714785600007723966234617067699739981186594316407453441278712559466777832168585522253954185379294762244445789937215692929032422902857113489749431542355577568771387268413221191470098683080004195644294492546278812309192571366173560735851643641505245838657818" editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L63" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">If we know both d and e, we can check our work by raising to the other exponent to get back to our original number.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L64" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"><EC-Button id="Buttonraisenumber2" caption="raise number2 to exponent" tooltip="raise number2 to exponent mod n" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.
num := parse(GetProperty(Textnumber2,'value'));
exponent :=  parse(GetProperty(Textexponent,'value'));
modulus :=  parse(GetProperty(Textmodulus,'value'));

if (type(num,integer)) then
  if (num &lt; modulus) then
    num2 := Power(num, exponent) mod modulus;
  else num2 := &quot;error, number too big for modulus&quot;;
  end if:
else num2 := &quot;error, number must be an integer.&quot;;
end if:

(SetProperty(Textnumber3,'value', num2));

end use; 
</MapleCode></EC-Button><EC-Button id="Button5" caption="copy d into exponent" tooltip="copy d from above into exponent" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

e := parse(GetProperty(Textd,'value'));
if not(type(e,integer)) then
  e := &quot;bad value&quot;;
end if:
SetProperty(Textexponent,'value',e);

end use; 
</MapleCode></EC-Button>  <EC-Button id="Button6" caption="copy e into exponent" tooltip="copy e from above into exponent" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

e := parse(GetProperty(Texte,'value'));
if not(type(e, integer)) then
  e := &quot;bad value&quot;;
end if;
SetProperty(Textexponent,'value',e);

end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L65" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">number3 = <EC-TextArea id="Textnumber3" tooltip="number2 to exponent" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="6" contents="31580729390886260418402933847506230651966415598469422" editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L66" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal">Finally, we can convert numbers back to ASCII.  If we have deciphered, this finally gives the message in readable form.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L28" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"><EC-Button id="Buttonnumbertoascii" caption="Convert number2 to ASCII" tooltip="convert number2 to text2" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

num1 := parse(GetProperty(Textnumber2,'value'));
l1 := []:
while num1 &gt; 0 do;
l1 := [op(l1), irem(num1, 256)];
num1 := iquo(num1, 256);
end do:
l1 := ListTools[Reverse](l1):
p3 := convert(l1,bytes);
SetProperty(Texttext2,'value',p3)

end use; 
</MapleCode></EC-Button><EC-Button id="Buttoncopyback" caption="Copy number2 back to number " tooltip="Check inverses" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.


num := parse(GetProperty(Textnumber2,'value'));
SetProperty(Textnumber,'value',num);

end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L67" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"><EC-Button id="Buttonconvertnumber3" caption="Convert number3 to ASCII" tooltip="convert number3 to text2" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.

num1 := parse(GetProperty(Textnumber3,'value'));
l1 := []:
while num1 &gt; 0 do;
l1 := [op(l1), irem(num1, 256)];
num1 := iquo(num1, 256);
end do:
l1 := ListTools[Reverse](l1):
p3 := convert(l1,bytes);
SetProperty(Texttext2,'value',p3)

end use; 
</MapleCode></EC-Button><EC-Button id="Buttoncopynumber3" caption="Copy number3 back to number " tooltip="Check inverses" pixel-width="300" pixel-height="200" enabled="true" visible="true" show-border="true" user-size="false"><MapleCode action="click-event-handler">use DocumentTools in 
# Enter Maple commands to be executed when the specified
# action is carried out on the component.
# Use: 
#    GetProperty( component_name, attribute_name )
# and
#    SetProperty( component_name, attribute_name, value )
# to access any of the attributes of the component.
# See ?CustomizingComponents for more information.


num := parse(GetProperty(Textnumber3,'value'));
SetProperty(Textnumber,'value',num);

end use; 
</MapleCode></EC-Button></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L68" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred">text2 = <EC-TextArea id="Texttext2" tooltip="number2 to ASCII" enabled="true" visible="true" visiblecharacterwidth="40" visiblerows="4" contents="This is a test of RSA." editable="true" wrapping="true"><MapleCode action="content-event-handler"></MapleCode></EC-TextArea></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L11" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal"></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L69" drawlabel="true">
<Input>
<Text-field style="Normal" layout="Normal" alignment="centred"></Text-field>
</Input>
</Group></Presentation-Block>
</Section><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L70" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal"></Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L71" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal">Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.</Text-field>
</Input>
</Group></Presentation-Block><Presentation-Block>
<Group view="presentation" hide-input="false" hide-output="true" inline-output="false" labelreference="L72" drawlabel="true">
<Input>
<Text-field style="Text" layout="Normal"><Equation executable="false" style="2D Math" input-equation="" display="LUklbXJvd0c2Iy9JK21vZHVsZW5hbWVHNiJJLFR5cGVzZXR0aW5nR0koX3N5c2xpYkdGJzYkLUkjbWlHRiQ2I1EhRicvJSxtYXRodmFyaWFudEdRJ25vcm1hbEYn">JSFH</Equation></Text-field>
</Input>
</Group></Presentation-Block>
</Worksheet>
