Simple Encryption
John Hunter
jdhunter at ace.bsd.uchicago.edu
Tue Nov 19 05:09:43 EST 2002
>>>>> "Bronek" == Bronek Carr <BCARR1 at uk.ibm.com> writes:
Bronek> Hi all, I am trying to write a simple ROT-13 encryption
Bronek> script in python. A good starting point would be a
Bronek> function which gets the ascii value of a character in a
Bronek> string. I would assume this function already exists in
Bronek> one of the packages, as it does in every other language I
Bronek> use. I cannot find it if it does, can anyone help me.
ord is what you want:
>>> ord('a')
97
It's inverse is chr:
>>> chr(ord('a'))
'a'
Not to stop you from having fun, but just wanted to let you know that
rot13 is a built-in string encoding in recent versions of python
>>> 'abc'.encode('rot13')
'nop'
John Hunter
More information about the Python-list
mailing list