Skip to main content

Signed snowflake ID's

Project description

Flakely

Allows for the generation and validation of SHA256 signed snowflakes.

Installation

pip install flakely

Usage

The flakely.Flakely class handles generation and validation of the signed snowflakes. It accepts the following arguemnts:

  • device: int a device ID that is encoded into each snowflake
  • process: int a process ID that is encoded into each snowflake
  • secret: str | bytes used to generate unpredictable signature hashes

Flakely.generate() -> int

Generates a new signed snowflake and returns it as an int.

Flakely.generate_bytes() -> bytes

Generates a new signed snowflake and returns it as a bytes object.

Flakely.validate(snowflake: int | bytes) -> bool

Checks that a snowflake's signature is valid for the payload.

Flakely.get_signature(flake: bytes) -> bytes

Generates a signature for the snowflake payload as SHA256 digest.

Flakely.get_tick() -> int

Returns an integer to use as the timestamp.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flakely-2024.1.31.tar.gz (2.2 kB view hashes)

Uploaded Source

Built Distribution

flakely-2024.1.31-py3-none-any.whl (2.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page