AsymCrypt optimize + Symcrypt creation
This commit is contained in:
@ -29,28 +29,29 @@ func TestGetKey(t *testing.T) {
|
||||
//}
|
||||
}
|
||||
|
||||
func TestEncryptDecrypt(t *testing.T) {
|
||||
func TestAsymEncryptDecrypt(t *testing.T) {
|
||||
kp := NewKeyPair()
|
||||
foo := "totoaimelesfrites!"
|
||||
encMess, err := Encrypt(kp.Public, []byte(foo))
|
||||
foo := []byte("!#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~")
|
||||
encMess, err := AsymEncrypt(kp.Public, foo)
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
decMess, err2 := Decrypt(kp.Private, encMess)
|
||||
println("len enc:", len(encMess))
|
||||
decMess, err2 := AsymDecrypt(kp.Private, encMess)
|
||||
if err2 != nil {
|
||||
log.Println(err2.Error())
|
||||
}
|
||||
assert.Equal(t, foo, decMess, "The two messages should be the same.")
|
||||
}
|
||||
|
||||
func TestEncryptDecryptSigned(t *testing.T) {
|
||||
func TestAsymEncryptDecryptSigned(t *testing.T) {
|
||||
kp := NewKeyPair()
|
||||
foo := "totoaimelesfrites!"
|
||||
encMess, sign, err := EncryptAndSign(kp.Public, kp.Private, []byte(foo))
|
||||
foo := "!#$%&()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{|}~"
|
||||
encMess, sign, err := AsymEncryptAndSign(kp.Public, kp.Private, []byte(foo))
|
||||
if err != nil {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
decMess, err2 := DecryptAndCheck(kp.Private, kp.Public, encMess, sign)
|
||||
decMess, err2 := AsymDecryptAndCheck(kp.Private, kp.Public, encMess, sign)
|
||||
if err2 != nil {
|
||||
log.Println(err2.Error())
|
||||
}
|
||||
|
Reference in New Issue
Block a user