Crate enid

Source
Expand description

An ENID (Encrypted Numeric Identifier) is a 40- or 80-bit value, which can be used as a unique identifier.

An example of a 40-bit ENID:

m6sc7n75

And an 80-bit ENID:

y3gx5gxm-mpb8ey39

ENIDs are generated by encrypting plaintext bytes so that they appear pseudo-random. The encrypted bytes are then formatted as a variant of Base32 (Crockford’s Base32) that excludes the letters i, l, o, and u. Each group of 40 bits is represented by 8 characters and separated by a hyphen.

This crate does not yet include a method for generating ENIDs, which will be added in a future version.

Some features of ENIDs:

  • Short - ENIDs are 8 or 17 characters long, compared with 36-character UUIDs.
  • Uniformly distributed - sequentially-generated ENIDs are unlikely to appear similar.
  • URL-safe - ENIDs can be used in URLs without percent-encoding.

§Crate features

  • arbitrary - adds Arbitrary implementations for fuzzing.
  • borsh - adds serialization and deserialization via borsh.
  • bytemuck - adds Pod implementations for byte manipulation.
  • serde - adds serialization and deserialization via serde.
  • slog - adds Value implementations for serialization.

Macros§

enid
Creates an Enid by parsing the given string at compile-time.
enid40
Creates an Enid40 by parsing the given string at compile-time.
enid80
Creates an Enid80 by parsing the given string at compile-time.

Structs§

Enid40
A 40-bit ENID.
Enid80
An 80-bit ENID.
EnidParseError
An error returned when parsing an invalid ENID string.

Enums§

Enid
An ENID, either 40 or 80 bits.