commit 25072e31d8a004dea0ba21578367a93e59b0f0db Author: Vincent Batts Date: Sat Feb 18 13:19:25 2017 -0500 initial diff --git a/app.go b/app.go new file mode 100644 index 0000000..f5a1cec --- /dev/null +++ b/app.go @@ -0,0 +1,45 @@ +package main + +import ( + "crypto/rand" + "crypto/rsa" + "crypto/sha1" + "crypto/x509" + "encoding/base32" + "encoding/pem" + "fmt" + "io" + "os" + "time" +) + +var enc = base32.NewEncoding("abcdefghijklmnopqrstuvwxyz234567") + +func main() { + pkey, err := rsa.GenerateKey(rand.Reader, 4096) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + fmt.Println(pkey.D) + fmt.Printf("%v\n", pkey.D.Bytes()) + + // get the DER encoded key + data := x509.MarshalPKCS1PrivateKey(pkey) + fmt.Printf("%v\n", data) + b := pem.Block{ + Bytes: data, + Type: "RSA PRIVATE KEY", + Headers: map[string]string{ + "date": time.Now().String(), + }, + } + data = pem.EncodeToMemory(&b) + fmt.Printf("%s\n", data) + + h := sha1.New() + io.WriteString(h, "His money is twice tainted:") + sum := h.Sum(nil) + + println(enc.EncodeToString(sum)[0:15]) +}