[Tutor] encryption

Katharine Stoner kstoner@netins.net
Tue, 22 May 2001 16:37:39 -0500


This is a multi-part message in MIME format.

------=_NextPart_000_001B_01C0E2DD.83CEECC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi to all python people,

I am working on a very simple encryption program.  The program replaces =
all of the keys on the keyboard to numbers.  The problem is that I =
cannot get letters to be traded for the numbers very easily.  I can't =
get it to be put in a function so when I make the GUI for encryption and =
decription.  I also need to be able to transform a message into the =
numbers through a loop in the translation function.  It gives me an =
error when I try and use the function to change letters to numbers.  It =
says name is not defined.  If someone would tell me what is wrong with =
this function.  I need a new aproach.
-thanks
Cameron

Here is what I have so far:

def letters(ltter):
    if ltter =3D=3D ' ':
        print '~'
    if ltter =3D=3D '':
        print '`'
    if ltter =3D=3D 'A':
        print '1'
    if ltter =3D=3D 'B':
        print '2'
    if ltter =3D=3D 'C':
        print '3'
    if ltter =3D=3D 'D':
        print '4'
    if ltter =3D=3D 'E':
        print '5'
    if ltter =3D=3D 'F':
        print '6'
    if ltter =3D=3D 'G':
        print '7'
    if ltter =3D=3D 'H':
        print '8'
    if ltter =3D=3D 'I':
        print '9'
    if ltter =3D=3D 'J':
        print '10'
    if ltter =3D=3D 'K':
        print '11'
    if ltter =3D=3D 'L':
        print '12'
    if ltter =3D=3D 'M':
        print '13'
    if ltter =3D=3D 'N':
        print '14'
    if ltter =3D=3D 'O':
        print '15'
    if ltter =3D=3D 'P':
        print '16'
    if ltter =3D=3D 'Q':
        print '17'
    if ltter =3D=3D 'R':
        print '18'
    if ltter =3D=3D 'S':
        print '19'
    if ltter =3D=3D 'T':
        print '20'
    if ltter =3D=3D 'U':
        print '21'
    if ltter =3D=3D 'V':
        print '22'
    if ltter =3D=3D 'W':
        print '23'
    if ltter =3D=3D 'X':
        print '24'
    if ltter =3D=3D 'Y':
        print '25'
    if ltter =3D=3D 'Z':
        print '26'



------=_NextPart_000_001B_01C0E2DD.83CEECC0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi to all python people,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am working on a very simple =
encryption=20
program.&nbsp; The program replaces all of the keys on the keyboard to=20
numbers.&nbsp; The problem is that I cannot get letters to be traded for =
the=20
numbers very easily.&nbsp; I can't get it to be put in a function so =
when I make=20
the GUI for encryption and decription.&nbsp; I also need to be able to =
transform=20
a message into&nbsp;the numbers through a loop in the translation=20
function.&nbsp; It gives me an error when I try and use the function to =
change=20
letters to numbers.&nbsp; It says name is not defined.&nbsp; If someone =
would=20
tell me what is wrong with this function.&nbsp; I need a new=20
aproach.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>-thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Cameron</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Here is what I have so =
far:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>def =
letters(ltter):<BR>&nbsp;&nbsp;&nbsp; if ltter=20
=3D=3D ' ':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'~'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'`'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'A':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'1'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'B':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'2'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'C':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'3'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'D':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'4'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'E':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'5'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'F':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'6'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'G':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'7'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'H':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'8'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'I':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'9'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'J':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'10'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'K':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'11'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'L':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'12'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'M':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'13'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'N':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'14'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'O':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'15'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'P':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'16'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'Q':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'17'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'R':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'18'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'S':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'19'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'T':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'20'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'U':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'21'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'V':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'22'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'W':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'23'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'X':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'24'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'Y':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print=20
'25'<BR>&nbsp;&nbsp;&nbsp; if ltter =3D=3D=20
'Z':<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print =
'26'</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_001B_01C0E2DD.83CEECC0--