1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-24 08:02:33 +03:00
croc/crypto_test.go
2017-10-17 21:15:48 -06:00

25 lines
485 B
Go

package main
import (
"fmt"
"testing"
)
func TestEncrypt(t *testing.T) {
key := GetRandomName()
fmt.Println(key)
salt, iv, encrypted := Encrypt([]byte("hello, world"), key)
fmt.Println(len(encrypted))
decrypted, err := Decrypt(salt, iv, encrypted, key)
if err != nil {
t.Error(err)
}
if string(decrypted) != "hello, world" {
t.Error("problem decrypting")
}
_, err = Decrypt(salt, iv, encrypted, "wrong passphrase")
if err == nil {
t.Error("should not work!")
}
}