Example #1
0
func TestSign(t *testing.T) {
	data := bytes.NewReader([]byte("this is a string to sign"))

	s, err := signature.Sign(privKey, data)
	if err != nil {
		t.Fatal(err)
	}

	if !bytes.Contains(s, []byte("SIGNATURE")) {
		t.Error("should be a signature")
	}
}
Example #2
0
func sign(keyname, dataname string) {
	privkey, err := ioutil.ReadFile(keyname)
	if err != nil {
		log.Fatal(err)
	}

	fd, err := os.Open(dataname)
	if err != nil {
		log.Fatal(err)
	}
	defer fd.Close()

	sig, err := signature.Sign(privkey, fd)
	if err != nil {
		log.Fatal(err)
	}

	os.Stdout.Write(sig)
}