-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathencode_test.go
More file actions
25 lines (18 loc) · 666 Bytes
/
Copy pathencode_test.go
File metadata and controls
25 lines (18 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package keys_test
import (
"testing"
"github.com/keys-pub/keys"
"github.com/stretchr/testify/require"
)
func TestEncodeDecodeKey(t *testing.T) {
sk := keys.GenerateEdX25519Key()
msg, err := keys.EncodeKeyToSaltpack(sk, "testpassword")
require.NoError(t, err)
t.Logf(msg)
_, err = keys.DecodeKeyFromSaltpack(msg, "invalidpassword", false)
require.EqualError(t, err, "failed to decrypt saltpack encoded key: failed to decrypt with a password: secretbox open failed")
skOut, err := keys.DecodeKeyFromSaltpack(msg, "testpassword", false)
require.NoError(t, err)
require.Equal(t, sk.Type(), skOut.Type())
require.Equal(t, sk.Bytes(), skOut.Bytes())
}