/Pontifex

Bruce Schneier's solitaire cipher from Cryptonomicon. Mostly just playin' with Python for the hell of it!

Primary LanguagePython

Pontifex
========

Bruce Schneier's solitaire cipher. See http://www.schneier.com/solitaire.html
(or read Cryptonomicon!) for more info.


How Do I Use It?
----------------

Like this, basically:

    from pont import encrypt, decrypt

    deck = range(1, 55) # don't actually do this
    plaintext = "hey there mister, I sure do like your pantaloons"
    ciphertext = encrypt(plaintext, deck)

    # then your partner-in-crime can decrypt thusly:
    deck = range(1, 55) # make sure to use the same key
    plaintext = decrypt(ciphertext, deck)

The deck argument is a list of integers, 1 through 54, representing a keyed
deck of cards. 1 through 13 is clubs, 14 through 26 is diamonds, 27 through 39
is hearts, and 40 through 52 is spades. The 'A' joker is 53 and the 'B' joker
is 54.


But I Love Passphrases!
-----------------------

You're in luck! You can also key your deck with a passphrase, like so:

    from pont import encrypt, decrypt, key_deck_with_passphrase

    deck = key_deck_with_passphrase("Oh shit this passphrase rulez!!1!!1!")
    plaintext = "lord love a duck, I'm really serious about those pants"
    ciphertext = encrypt(plaintext, deck)

    # now your pant-friend can decrypt like above
    deck = key_deck_with_passphrase("Oh shit this passphrase rulez!!1!!1!")
    plaintext = decrypt(ciphertext, deck)

Note that Schneier recommends at least 80 characters for your passphrase.