[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> </DIV>
<DIV><FONT face=3DArial size=3D2>I am working on a very simple =
encryption=20
program. The program replaces all of the keys on the keyboard to=20
numbers. The problem is that I cannot get letters to be traded for =
the=20
numbers very easily. I can't get it to be put in a function so =
when I make=20
the GUI for encryption and decription. I also need to be able to =
transform=20
a message into the numbers through a loop in the translation=20
function. It gives me an error when I try and use the function to =
change=20
letters to numbers. It says name is not defined. If someone =
would=20
tell me what is wrong with this function. 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> </DIV>
<DIV><FONT face=3DArial size=3D2>Here is what I have so =
far:</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2>def =
letters(ltter):<BR> if ltter=20
=3D=3D ' ':<BR> print=20
'~'<BR> if ltter =3D=3D=20
'':<BR> print=20
'`'<BR> if ltter =3D=3D=20
'A':<BR> print=20
'1'<BR> if ltter =3D=3D=20
'B':<BR> print=20
'2'<BR> if ltter =3D=3D=20
'C':<BR> print=20
'3'<BR> if ltter =3D=3D=20
'D':<BR> print=20
'4'<BR> if ltter =3D=3D=20
'E':<BR> print=20
'5'<BR> if ltter =3D=3D=20
'F':<BR> print=20
'6'<BR> if ltter =3D=3D=20
'G':<BR> print=20
'7'<BR> if ltter =3D=3D=20
'H':<BR> print=20
'8'<BR> if ltter =3D=3D=20
'I':<BR> print=20
'9'<BR> if ltter =3D=3D=20
'J':<BR> print=20
'10'<BR> if ltter =3D=3D=20
'K':<BR> print=20
'11'<BR> if ltter =3D=3D=20
'L':<BR> print=20
'12'<BR> if ltter =3D=3D=20
'M':<BR> print=20
'13'<BR> if ltter =3D=3D=20
'N':<BR> print=20
'14'<BR> if ltter =3D=3D=20
'O':<BR> print=20
'15'<BR> if ltter =3D=3D=20
'P':<BR> print=20
'16'<BR> if ltter =3D=3D=20
'Q':<BR> print=20
'17'<BR> if ltter =3D=3D=20
'R':<BR> print=20
'18'<BR> if ltter =3D=3D=20
'S':<BR> print=20
'19'<BR> if ltter =3D=3D=20
'T':<BR> print=20
'20'<BR> if ltter =3D=3D=20
'U':<BR> print=20
'21'<BR> if ltter =3D=3D=20
'V':<BR> print=20
'22'<BR> if ltter =3D=3D=20
'W':<BR> print=20
'23'<BR> if ltter =3D=3D=20
'X':<BR> print=20
'24'<BR> if ltter =3D=3D=20
'Y':<BR> print=20
'25'<BR> if ltter =3D=3D=20
'Z':<BR> print =
'26'</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV></BODY></HTML>
------=_NextPart_000_001B_01C0E2DD.83CEECC0--