mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
Fix tests
This commit is contained in:
parent
cb83c7082d
commit
7ce613531c
1 changed files with 3 additions and 6 deletions
|
@ -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!")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue