Skip to main content

A simple CLI tool to generate API Key

Project description

api-key-factory

Software License semantic-release: angular Pipeline Status

Built with Material for MkDocs Source code documentation

Logo of api-key-factory

Overview

api-key-factory is a CLI tool to generate API keys and their corresponding SHA-256 hashes. The secret part of the key is an UUID (Universally Unique Identifier) version 4 (random).

Example of generated a API key:

mykey-8590efb6-0a68-4390-8537-99a54928c669
Usage: api-key-factory [OPTIONS] COMMAND [ARGS]...

  A simple CLI tool to generate API keys and their corresponding SHA-256
  hashes.

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  generate  Command to generate API keys and their corresponding SHA-256...

generate

Generate api keys and hashes in standart terminal output (stdout) or in 2 distinct files ([prefix_]keys.txt, [prefix_]hashes.txt) in a defined directory.

Usage: api-key-factory generate [OPTIONS]

  Command to generate API keys and their corresponding SHA-256 hashes.

  Args:     output_dir (click.Path): Directory to output keys and hashes.
  num (int): Number of API keys to generate. Default 1.     prefix (str):
  Prefix at the beginning of the key.

  Raises:     click.ClickException: Error when writing output files

Options:
  -d, --dir DIRECTORY      Directory to output keys and hashes. If not set
                           output to stdout.
  -n, --num INTEGER RANGE  Number of API keys to generate  [x>=1]
  -p, --prefix TEXT        Add a prefix at the beginning of the key
  --help                   Show this message and exit.

Example:

$ api-key-factory generate --num 2
d097dccc-cd24-4137-8ddb-d03f8b07d8d9   8b89600015b273c28f966f368456e45e01df239a36bf939ff72a16881f775679
c2d79a40-388e-4709-9e4b-903035b0e71e   fb22be500af1ef0479745bbbce847854da33f5e910361ad278e0282995b95f4d
$ api-key-factory generate --prefix mykey
mykey-3532dceb-f38a-491b-814d-9607bc9a947a   83309f0b7cd16fbd02edc85dbe32fc3326367618cf80a885f649d8e4eaeb43b3
$ api-key-factory generate -p mykey -n 5 --dir out
Success! 5 keys and hashes have been written to the files:
 - out/mykey_keys.txt
 - out/mykey_hashes.txt

Installation

With Python environment

To use:

  • Minimal Python version: 3.10

Installation with Python pip:

python3 -m pip install api-key-factory
api-key-factory --help

Developement

With uv and Task

To use:

# Set environment
uv sync
# Format
task 00:10-format
# Lint
task 00:20-lint
# Tests
task 00:40-test
# Run
uv run api-key-factory --help

Authors

License

This program is free software: you can redistribute it and/or modify it under the terms of the MIT License (MIT). See the LICENSE for details.

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

api_key_factory-1.3.13.tar.gz (7.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

api_key_factory-1.3.13-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file api_key_factory-1.3.13.tar.gz.

File metadata

  • Download URL: api_key_factory-1.3.13.tar.gz
  • Upload date:
  • Size: 7.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for api_key_factory-1.3.13.tar.gz
Algorithm Hash digest
SHA256 e276d30b0a3a73724c67ac80e7cf201f3589ad144d32bf44a6f11e4d050190ed
MD5 c8e098179ba6d4c480e82306fc1e1040
BLAKE2b-256 14e7008a94cc6bd12043fea384ad4749fd4e5bf5abd3d273790365f6df52bd11

See more details on using hashes here.

File details

Details for the file api_key_factory-1.3.13-py3-none-any.whl.

File metadata

  • Download URL: api_key_factory-1.3.13-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for api_key_factory-1.3.13-py3-none-any.whl
Algorithm Hash digest
SHA256 edafec178eea48972d52f22f04f8755443e0c2c31269beef8aad8acd076b538b
MD5 ce03a1084502974386f39182747b6251
BLAKE2b-256 f019b12d53452a6bd42260f6b8b572242956b2aa0d3456fdd001a40c4b308c0a

See more details on using hashes here.

Supported by

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