Day: March 31, 2005

  • More Python for Series 60 Crypto: Rijndael

    Rijndael on Series 60

    During my search for pure python Nirvana I came across Bram Cohen‘s rijndael.py. It can work with strings of length 16, 24, or 32. Here’s the sample code that ran successfully (albeit slowly) on my Taco:

    # Make sure rijndael.py is in your libs dir
    from rijndael import rijndael
    # key must be 16, 24, 32 characters long
    key = 'sixteencharacter'
    r = rijndael(key, 16)
    # must encode/decode in the chosen blocksize
    print 'Encoding/Decodingnusing Rijndael...'
    plaintext = 'themonkeygoeswoo'
    ciphertext = r.encrypt(plaintext)
    print r.decrypt(ciphertext)

    It took its sweet time to run, but isn’t much more painful than waiting for import urllib, so it’s not the end of the world. It requires copy and string, which I’m not sure are in the Nokia distribution, but it works just fine if you dump the Python 2.2.2 source libraries in to your libs directory.

    Add this one to your mobile cryptography toolbelt.