package starcrypto import ( "fmt" "testing" ) func TestRsaCrypt(t *testing.T) { privKey, pubKey, err := GenerateRsaKey(2048) if err != nil { panic(err) } data, err := RSAEncryptByPrivkey(privKey, []byte("hello world")) if err != nil { t.Fatal(err) } code, err := RSADecryptByPubkey(pubKey, data) if err != nil { t.Fatal(err) } fmt.Println(string(code)) if string(code) != "hello world" { t.Fail() } } func TestHmacSHA224(t *testing.T) { key := []byte("hello world") data := []byte("hello world") code := HmacSHA224Str(key, data) if "1414427f4b2889c3e86e637162c1add2bb888d1fc6c405d05fa5b66b" != code { t.Fail() } }