1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-24 08:02:33 +03:00

Fix tests

This commit is contained in:
Zack Scholl 2017-10-18 10:29:41 -06:00
parent cb83c7082d
commit 7ce613531c

View File

@ -1,23 +1,20 @@
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)
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(salt, iv, encrypted, "wrong passphrase")
_, err = Decrypt(encrypted, "wrong passphrase", salt, iv)
if err == nil {
t.Error("should not work!")
}