Skip to content

Commit ae38481

Browse files
committed
Document compact encoding.
1 parent 975645c commit ae38481

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,24 @@ registered first using gob.Register(). For basic types this is not needed;
7777
it works out of the box. An optional JSON encoder that uses `encoding/json` is
7878
available for types compatible with JSON.
7979

80+
### Compact Encoding
81+
82+
Original encoding adds a lot of unnecessary overhead for encoded value.
83+
Therefore new encoding is added to reduce length of cookie. To simplify
84+
migration, same SecureCookie instance may decode both original and compact
85+
encodings, but generates those you choose to. By default original encoding
86+
is used therefore you may safely update this library without code change.
87+
88+
```go
89+
var s = securecookie.New(hashKey, blockKey)
90+
s.Compact(true) // enable generation of compact encoding.
91+
s.Compact(false) // disable generation of compact encoding. It is default.
92+
```
93+
94+
Not that algorithms are fixed with compact encoding: ChaCha20 is used for
95+
stream cipher and Blake2s is used as a MAC and key expansion (to meet ChaCha20
96+
requirements for key length).
97+
8098
### Key Rotation
8199
Rotating keys is an important part of any security strategy. The `EncodeMulti` and
82100
`DecodeMulti` functions allow for multiple keys to be rotated in and out.

0 commit comments

Comments
 (0)