7 "github.com/stretchr/testify/assert"
10func TestEncodeAndDecodeAccessToken(t *testing.T) {
11 const secret = "0123456789abcdefghijklmnopqrstuv"
12 const token = "my access token"
13 c, err := NewCipher([]byte(secret))
14 assert.Equal(t, nil, err)
16 encoded, err := c.Encrypt(token)
17 assert.Equal(t, nil, err)
19 decoded, err := c.Decrypt(encoded)
20 assert.Equal(t, nil, err)
22 assert.NotEqual(t, token, encoded)
23 assert.Equal(t, token, decoded)
26func TestEncodeAndDecodeAccessTokenB64(t *testing.T) {
27 const secretBase64 = "A3Xbr6fu6Al0HkgrP1ztjb-mYiwmxgNPP-XbNsz1WBk="
28 const token = "my access token"
30 secret, err := base64.URLEncoding.DecodeString(secretBase64)
31 assert.Equal(t, nil, err)
32 c, err := NewCipher([]byte(secret))
33 assert.Equal(t, nil, err)
35 encoded, err := c.Encrypt(token)
36 assert.Equal(t, nil, err)
38 decoded, err := c.Decrypt(encoded)
39 assert.Equal(t, nil, err)
41 assert.NotEqual(t, token, encoded)
42 assert.Equal(t, token, decoded)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list