mirror of
https://github.com/schollz/croc.git
synced 2024-11-24 08:02:33 +03:00
22 lines
431 B
Go
22 lines
431 B
Go
package main
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestEncrypt(t *testing.T) {
|
|
key := GetRandomName()
|
|
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")
|
|
}
|
|
_, err = Decrypt(encrypted, "wrong passphrase", salt, iv)
|
|
if err == nil {
|
|
t.Error("should not work!")
|
|
}
|
|
}
|