Example #1
0
func testHmac(t *testing.T, en platform.Encryptor, s1 []byte) {
	b1 := en.Sum(s1)
	b2 := en.Sum(s1)
	t.Logf("HMAC(%s)=%s", s1, hex.EncodeToString(b1))
	t.Logf("HMAC(%s)=%s", s1, hex.EncodeToString(b2))
	if !en.Equal(s1, b1) {
		t.Fatalf("error on check")
	}
}
Example #2
0
func testAes(t *testing.T, en platform.Encryptor, s1 []byte) {
	if buf, err := en.Encode(s1); err == nil {
		t.Logf("AES(%s)=%s", s1, hex.EncodeToString(buf))
		if s2, err := en.Decode(buf); err == nil {
			t.Logf("get %s", s2)
			if string(s2) != string(s1) {
				t.Fatalf("want %s, get %s", s1, s2)
			}
		} else {
			t.Fatal(err)
		}
	} else {
		t.Fatal(err)
	}
}