(t *testing.T)
| 83 | } |
| 84 | |
| 85 | func TestKeyDerivation(t *testing.T) { |
| 86 | folderKey := testKeyGen.KeyFromPassword("my folder", "my password") |
| 87 | encryptedName := encryptDeterministic([]byte("filename.txt"), folderKey, nil) |
| 88 | if base32Hex.EncodeToString(encryptedName) != "3T5957I4IOA20VEIEER6JSQG0PEPIRV862II3K7LOF75Q" { |
| 89 | t.Error("encrypted name mismatch") |
| 90 | } |
| 91 | |
| 92 | fileKey := testKeyGen.FileKey("filename.txt", folderKey) |
| 93 | // fmt.Println(base32Hex.EncodeToString(encryptBytes([]byte("hello world"), fileKey))) => A1IPD... |
| 94 | const encrypted = `A1IPD28ISL7VNPRSSSQM2L31L3IJPC08283RO89J5UG0TI9P38DO9RFGK12DK0KD7PKQP6U51UL2B6H96O` |
| 95 | bs, _ := base32Hex.DecodeString(encrypted) |
| 96 | dec, err := DecryptBytes(bs, fileKey) |
| 97 | if err != nil { |
| 98 | t.Error(err) |
| 99 | } |
| 100 | if string(dec) != "hello world" { |
| 101 | t.Error("decryption mismatch") |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | func TestDecryptNameInvalid(t *testing.T) { |
| 106 | key := new([32]byte) |
nothing calls this directly
no test coverage detected