1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-28 01:16:10 +03:00
croc/crypto_test.go

22 lines
431 B
Go
Raw Normal View History

package main
import (
"testing"
)
func TestEncrypt(t *testing.T) {
key := GetRandomName()
2017-10-18 19:29:41 +03:00
encrypted, salt, iv := Encrypt([]byte("hello, world"), key)
decrypted, err := Decrypt(encrypted, key, salt, iv)
if err != nil {
t.Error(err)
}
if string(decrypted) != "hello, world" {
t.Error("problem decrypting")
}
2017-10-18 19:29:41 +03:00
_, err = Decrypt(encrypted, "wrong passphrase", salt, iv)
if err == nil {
t.Error("should not work!")
}
}