0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02: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 package main
import ( import (
"fmt"
"testing" "testing"
) )
func TestEncrypt(t *testing.T) { func TestEncrypt(t *testing.T) {
key := GetRandomName() key := GetRandomName()
fmt.Println(key) encrypted, salt, iv := Encrypt([]byte("hello, world"), key)
salt, iv, encrypted := Encrypt([]byte("hello, world"), key) decrypted, err := Decrypt(encrypted, key, salt, iv)
fmt.Println(len(encrypted))
decrypted, err := Decrypt(salt, iv, encrypted, key)
if err != nil { if err != nil {
t.Error(err) t.Error(err)
} }
if string(decrypted) != "hello, world" { if string(decrypted) != "hello, world" {
t.Error("problem decrypting") t.Error("problem decrypting")
} }
_, err = Decrypt(salt, iv, encrypted, "wrong passphrase") _, err = Decrypt(encrypted, "wrong passphrase", salt, iv)
if err == nil { if err == nil {
t.Error("should not work!") t.Error("should not work!")
} }