Skip to content

Commit

Permalink
Add test for decrypting
Browse files Browse the repository at this point in the history
  • Loading branch information
heppu committed Sep 26, 2023
1 parent 9ec413d commit 57b15b5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions crypto_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ func ExampleBase64encode() {
// Output: U1VDQ0VTUw==
}

func TestDecrypt(t *testing.T) {
// This test makes sure that we don't brake backwards compatibility
// by modifying both; encrypt and decrypt at the same time.
const passwd = "mypass"
var (
encryptedInput = []byte{
0xf2, 0x3, 0x92, 0x1f, 0x9b, 0xb4, 0x56, 0xc,
0x37, 0xb4, 0x33, 0x5f, 0x1, 0xad, 0xe3, 0x66,
0x99, 0x14, 0x3e, 0x59, 0xc9, 0x19, 0xfe, 0x3b,
0x6f, 0x34, 0xd2, 0xd9, 0x80, 0xe7, 0x1f, 0x2f,
0xf2, 0x15, 0xb1, 0x4, 0x3e,
}
expectedOutput = []byte("some data")
)

data, err := Decrypt(encryptedInput, passwd)
require.NoError(t, err)
require.Equal(t, expectedOutput, data)
}

func TestEncryptDecrypt(t *testing.T) {
const (
input = "supersecret"
Expand Down

0 comments on commit 57b15b5

Please sign in to comment.