Skip to main content

Tool for quick necessary stuff

Project description

Keyra - Key Random Access

Keyra (key random access) is the successor to pyness - a comprehensive Python utility module designed to simplify common development tasks with secure key generation, datetime utilities, and filename management.

What is Keyra?

Keyra is a simple yet powerful module that covers essential utilities for your projects and work. While the individual functions are straightforward, this module helps you accomplish tasks quickly and reduces code complexity. It's particularly useful for:

  • Secure key generation with customizable character sets
  • Password and token creation for authentication systems
  • Filename management with timestamps and safe naming
  • Date/time utilities for logging and file organization
  • Auto-incrementing sequences for batch processing

Successor to Pyness

This module builds upon the concepts from pyness but with significant improvements:

  • Enhanced security with better character sets and validation
  • More comprehensive datetime utilities
  • Improved filename handling and safety
  • Better error handling and user experience
  • Expanded functionality for modern development needs

Install

pip install keyra

Quick Start

Basic Key Generation

import keyra

# Generate a simple 8-character key
key = keyra.key(8)
print(key)  # e.g., "Kj9#mN2@"

# Generate only numbers
pin = keyra.key(4, number=True, upper=False, lower=False, symbol=False)
print(pin)  # e.g., "8472"

Advanced Key Generation

# Generate with specific character counts
key = keyra.key(10, number=3, upper=4, lower=2, symbol=1)
print(key)  # e.g., "Kj9#mN2@Xy"

# Use custom character sets
key = keyra.key(6, number="123", upper="ABC", lower=False, symbol=False)
print(key)  # e.g., "A1B2C3"

Password and Token Generation

# Generate secure passwords
password = keyra.generate_password(12)  # 12-character secure password
pin = keyra.generate_pin(6)             # 6-digit numeric PIN
token = keyra.generate_token(32)        # 32-character secure token

Datetime & Filename Utilities

# Append timestamps to filenames
base_name = keyra.key(6)
filename = keyra.append_timestamp(base_name)  # e.g., "Kj9#mN_20250731_173025"

# For OpenCV image saving
import cv2
frame = cv2.imread("input.jpg")
filename = keyra.append_timestamp("frame", fmt="%Y%m%d_%H%M%S") + ".jpg"
cv2.imwrite(filename, frame)

# Auto-incrementing sequences
fname1 = keyra.auto_increment_suffix("img", 1)  # img_001
fname2 = keyra.auto_increment_suffix("img", 2)  # img_002

# Safe filenames
safe = keyra.make_filename_safe("my:illegal*file?.jpg")  # my_illegal_file_.jpg

Features

Core Functions

  • key(): Main key generation with customizable constraints
  • generate_password(): Generate secure passwords
  • generate_pin(): Generate numeric PINs
  • generate_token(): Generate secure tokens

Datetime Utilities

  • append_date(): Append current date to strings
  • append_timestamp(): Append timestamp to strings
  • append_datetime(): Append datetime with microseconds
  • get_formatted_date(): Get current date string
  • get_formatted_timestamp(): Get current timestamp string

Filename Utilities

  • auto_increment_suffix(): Auto-incrementing suffix for sequences
  • make_filename_safe(): Directory-safe filenames
  • add_extension(): Extension handler for files

Use Cases

  • API Key Generation: Create secure tokens for API authentication
  • Password Management: Generate strong passwords for user accounts
  • File Organization: Create timestamped filenames for data processing
  • Batch Processing: Auto-incrementing filenames for image/video processing
  • Logging: Timestamped log files and entries
  • Testing: Generate test data and identifiers

Update Log

  • Version 1.0.0: Complete rewrite with improved key generation
  • Enhanced security with better character sets
  • Added utility functions for common use cases
  • Improved error handling and validation
  • Added datetime utility functions for filename generation
  • Added filename utilities: auto-increment, safe filenames, extension handler

Contributing

If you encounter any issues, please create an issue on GitHub. This module is designed to be simple and reliable, but we welcome feedback and improvements.

License

MIT License - feel free to use this module in your projects.

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

keyra-1.0.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

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

keyra-1.0.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file keyra-1.0.0.tar.gz.

File metadata

  • Download URL: keyra-1.0.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for keyra-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c9ceca8e0ece76747c5e5341fd341277cdd70b17668413931606e9160d59ed9c
MD5 1f8ae2542b8b40ca511179f725769dfc
BLAKE2b-256 cf82ae37da81e37f3ea156d740e82ef779b0622bee0f3d6d8b60f49b165b23e6

See more details on using hashes here.

File details

Details for the file keyra-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: keyra-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for keyra-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f635ca25e24115d02e37d42fa915ec82ea5c21ff4b6cbf282fbccd6ea98b3b3b
MD5 71e57fc467a1ffcf9658fcbac4d60a92
BLAKE2b-256 82b539d0a8f0fdf32d2f0ab3385cb126ef3c10cce6cb43fe05284b977c117bf8

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