refactored to move no longer shared things out of the shared/ folder

This commit is contained in:
David Dworken
2022-04-07 20:59:40 -07:00
parent a8d7ee2cc8
commit c2465d7c99
10 changed files with 253 additions and 253 deletions

23
client/data/data_test.go Normal file
View File

@ -0,0 +1,23 @@
package data
import (
"testing"
"github.com/ddworken/hishtory/shared"
)
func TestEncryptDecrypt(t *testing.T) {
k1 := EncryptionKey("key")
k2 := EncryptionKey("key")
if string(k1) != string(k2) {
t.Fatalf("Expected EncryptionKey to be deterministic!")
}
ciphertext, nonce, err := Encrypt("key", []byte("hello world!"), []byte("extra"))
shared.Check(t, err)
plaintext, err := Decrypt("key", ciphertext, []byte("extra"), nonce)
shared.Check(t, err)
if string(plaintext) != "hello world!" {
t.Fatalf("Expected decrypt(encrypt(x)) to work, but it didn't!")
}
}