Branca
Inherits Reference < Object
Constants
VERSION = 186
Constructors
new(key : Bytes)
Creates a new Branca instance.
Make sure you use a secure encryption key:
key = Bytes.new(32)
Random::Secure.random_bytes(key)
branca = Branca.new key
Instance methods
decode(str : String, ttl : UInt32 = 0) : Token
Decodes a Base62 encoded Branca Token.
If ttl is greater than 0 and the token is expired, an ExpiredTokenError is raised.
encode(payload : String | Bytes, timestamp : UInt32 = Time.utc.to_unix.to_u32) : String
Creates a XChaCha20-Poly1305 AEAD encrypted Branca Token.
Returns a Base62 encoded String.
encode(token : Token) : String
Source