Bijou64 is a purely canonical variable length encoding for u64 integers.
Each integer can only be represented by a single encoded value, which aids security if the data is signed.
Summary
Functions
Decodes valid u64 integers according to the bijou64 format from the start of a binary.
Encodes valid u64 integers according to the bijou64 format.
Types
Functions
Decodes valid u64 integers according to the bijou64 format from the start of a binary.
iex> Bijou64.decode(<<0>>)
{0, ""}
iex> Bijou64.decode(<<247>>)
{247, ""}
iex> Bijou64.decode(<<248, 0>>)
{248, ""}
iex> Bijou64.decode(<<255, 254, 254, 254, 254, 254, 254, 254, 7>>)
{18446744073709551615, ""}
Encodes valid u64 integers according to the bijou64 format.
iex> Bijou64.encode(0)
<<0>>
iex> Bijou64.encode(247)
<<247>>
iex> Bijou64.encode(248)
<<248, 0>>
iex> Bijou64.encode(2 ** 64 - 1)
<<255, 254, 254, 254, 254, 254, 254, 254, 7>>