-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathhash_func_test.go
33 lines (22 loc) · 1.17 KB
/
hash_func_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package signature
import (
"github.com/stretchr/testify/assert"
"testing"
)
/*
func TestHash(t *testing.T) {
assert.Equal(t, SHA1Hash, Hash)
}
*/
func TestSHA1Hash(t *testing.T) {
assert.Equal(t, SHA1Hash("abc"), "a9993e364706816aba3e25717850c26c9cd0d89d")
}
func TestMD5Hash(t *testing.T) {
assert.Equal(t, MD5Hash("abc"), "900150983cd24fb0d6963f7d28e17f72")
}
func TestHashWithPrivateKey(t *testing.T) {
assert.Equal(t, HashWithKeys([]byte("some bytes to hash"), []byte("public key"), []byte("private key")), "4c9ac9d6594e19c0bcbfcc261f82e190cf222526")
assert.NotEmpty(t, HashWithKeys([]byte("some bytes to hash"), []byte("public key"), []byte("private key")), HashWithKeys([]byte("some bytes to hash"), []byte("public key"), []byte("different private key")))
assert.NotEmpty(t, HashWithKeys([]byte("some bytes to hash"), []byte("public key"), []byte("private key")), HashWithKeys([]byte("some bytes to hash"), []byte("different public key"), []byte("private key")))
assert.NotEmpty(t, HashWithKeys([]byte("some bytes to hash"), []byte("public key"), []byte("private key")), HashWithKeys([]byte("different bytes to hash"), []byte("public key"), []byte("private key")))
}