This is itended as a "clean-room" implementation of the Solitaire algorithm created by Bruce Schneier and used in the novel Cryptonomicon.
The only source material I will be using is the description of the algorithm from Bruce's website. I have read the Perl code in the book, but I have not taken the time to grok it in any meaningful sense.
The basic usage is to create a deck, likely keyed by a passphrase. Then, encrypt or decrypt strings on that deck.
package main
import (
"fmt"
"github.com/jmhobbs/pontifex"
)
func main() {
deck, _ := pontifex.NewDeckForPassphrase("CRYPTONOMICON")
ciphertext, _ := deck.Encrypt("SOLITAIRE")
fmt.Println(ciphertext)
plaintext, _ := deck.Decrypt(ciphertext)
fmt.Println(plaintext)
}
$ pontifex
usage: pontifex [encrypt|decrypt] <passphrase> <ciphertext|plaintext>
$ pontifex encrypt CRYPTONOMICON SOLITAIRE
KIRAKSFJA
$ pontifex decrypt CRYPTONOMICON KIRAKSFJA
SOLITAIRE