Serpent in GoIn 2000/2001, NIST ran a competition on the next generation symmetric key method, and Rijndael won (and which was created by its Belgium creators: Vincent Rijmen and Joan Daemen). But in second place was Serpent, and which was created by Ross Anderson, Eli Biham and Lars Knudsen. |
Code
The following is some sample code:
package main import ( "github.com/enceve/crypto/serpent" "fmt" "crypto/rand" "os" "bytes" ) func main() { msg:="abc" argCount := len(os.Args[1:]) if (argCount>0) {msg= string(os.Args[1])} key := make([]byte, 16) _, _ = rand.Read(key) c, _ := serpent.NewCipher(key) var src [32]byte copy(src[:], msg) dst := make([]byte, 32) c.Encrypt(dst, src[:]) fmt.Printf("Key:\t%x\n",key) fmt.Printf("Cipher:\t%x\n",dst) c.Decrypt(dst, dst) dst=bytes.Trim(dst, "\x00") fmt.Printf("Decrypted: %s",string(dst)) }
And a sample run:
Key: 5bfbb8f09ea47e56a0a27008b6037c4a Cipher: 0fbfc075154a4041a2fc5dab2612fdf100000000000000000000000000000000 Decrypted: Testing 123