Documentation ¶
Index ¶
Constants ¶
View Source
const ( // MaxInt represents the upper bound. // It should be 2^N. // It is set by default to the upper bound of an (2^53 - 1) // which represents the maximum safe integer(Number.MAX_SAFE_INTEGER) in JavaScript. MaxInt = 1<<53 - 1 // 2,147,483,647 // MillerRabin is used to configure the ProbablyPrime function // which is used to verify prime numbers. // See: https://golang.org/pkg/math/big/#Int.ProbablyPrime MillerRabin = 20 )
Variables ¶
This section is empty.
Functions ¶
func DeObfuscate ¶
DeObfuscate is used to decode n back to the original id. It will only decode correctly if the prime selectors is consistent with what was used to encode n.
Types ¶
type ID ¶
type ID uint64
func ParseID ¶
ParseID is an inverse operation of ID.String(), returns zero if any error occurs during parsing.
func (*ID) MarshalJSON ¶
MarshalJSON satisfies json.Marshaller and transparently obfuscates the value using Default prime
func (*ID) String ¶
String returns the obfuscated id in base64 string format and with little-endian byte order.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON satisfies json.Marshaller and transparently deobfuscates the value using inverse of Default prime
Click to show internal directories.
Click to hide internal directories.