Skip to main content

A brief tool to analyse and generate entropic passwords and keys.

Project description

secgen

A comprehensive, secure, and highly configurable Python library for credential generation and entropy analysis.

This package provides developers with the tools to generate deterministic passwords, cryptographically secure tokens, numeric PINs, and mnemonic passwords. Additionally, it features an advanced analysis module to evaluate password strength through entropy calculations and brute-force crack time estimations.

Features

  • Password Generation: Create highly secure passwords with customizable length and character sets (uppercase, numbers, symbols).
  • Bulk Generation: Generate large batches of secure passwords efficiently.
  • Token & PIN Creation: Generate cryptographically secure hexadecimal tokens and numeric PINs.
  • Mnemonic Passwords: Generate memorable yet secure passwords using customizable data streams.
  • Entropy Analysis: Calculate the cryptographic strength of a password based on character pool and length.
  • Crack Time Estimation: Estimate the time required to brute-force a password using modern hardware capabilities.

Installation

You can install the package directly via pip:

pip install secgen

Usage

1. Credential Generation (generator.py)

The generator module provides multiple functions to create different types of security credentials.

Standard Password Generation

Generate a single password with specific constraints.

from secgen.generator import generate_password

# Generate a 24-character password with uppercase letters, numbers, and symbols
secure_pwd = generate_password(length=24, uppercase_letters=True, numbers=True, symbols=True)
print(secure_pwd)
# Output example: 'A$5xpu!23lzQ34?#u4v8K9@z'

Bulk Password Generation

Generate a list of passwords, ideal for administrative purposes or initial database seeding.

from secgen.generator import generate_bulk_pwd

# Generate 5 passwords, each 12 characters long
bulk_pwds = generate_bulk_pwd(num=5, length=12, uppercase_letters=True, numbers=True, symbols=False)
print(bulk_pwds)
# Output example: ['aB3dEfg8Hijk', 'L1mnOpq2RstU', ...]

PIN and Token Generation

Generate purely numeric PINs and secure hexadecimal tokens.

from secgen.generator import generate_pin, generate_token

# Generate a 6-digit PIN
user_pin = generate_pin(length=6)
print(user_pin) 
# Output example: '492018'

# Generate a 32-byte secure hexadecimal token
session_token = generate_token(bytes=32)
print(session_token) 

Mnemonic Password Generation

Generate symbolic passwords based on memorability levels.

Important requirement: This function requires a data directory containing a mnemotechnic_stream.json file relative to the generator module's location.

from secgen.generator import generate_symbolic_mnemopwd

# Generate a standard mnemonic password with medium complexity
mnemo_pwd = generate_symbolic_mnemopwd(lvl="medium", composition="standard")
print(mnemo_pwd)

2. Password Analysis (analysis.py)

The analysis module evaluates password strength by calculating entropy bits and estimating brute-force vulnerability.

Analyze a Single Password

from secgen.analysis import analyze_one

result = analyze_one('A$5xpu!23lzQ34?#u4', crack_time=True)

print(result['crack_time']) 
# Output example: 'Millenia (Imposible with the actual technology)'

print(result['feedback']) 
# Output example: '\033[92mExcellent\033[0m' (Terminal colored output)

Note: The feedback string includes ANSI color codes (Red, Yellow, Blue, Green) to render colored text directly in standard terminal environments.

Analyze Multiple Passwords (Bulk)

from secgen.analysis import analyze_many

passwords_to_check = ['A$5xpu!23lzQ34?#u4', 'FroDobolSon', 'a']
bulk_results = analyze_many(passwords_to_check)

for idx, data in enumerate(bulk_results):
    print(f"Password {idx + 1}:")
    print(f" - Strength: {data['feedback']}")
    print(f" - Crack Time: {data['crack_time']}\n")

Dependencies

This library is built exclusively using Python's standard library modules (random, os, json, secrets, math) to ensure zero external dependencies and maximum security compatibility.

License

This project is licensed under the GNU General Public License v3.0. You are free to redistribute it and/or modify it under the terms of the Free Software Foundation. See the LICENSE file provided with the source code for more 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

secgen-0.3.2.tar.gz (26.4 kB view details)

Uploaded Source

Built Distribution

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

secgen-0.3.2-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file secgen-0.3.2.tar.gz.

File metadata

  • Download URL: secgen-0.3.2.tar.gz
  • Upload date:
  • Size: 26.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for secgen-0.3.2.tar.gz
Algorithm Hash digest
SHA256 946b29f6d4996851ebd701a0cd04f3b5c867fbfeab66f16b9270372cf88a6ed3
MD5 9935db72f3e3d8f844a763119dd308fb
BLAKE2b-256 6b32d2d6d7c7e73caf7edd9f5b41a38e0ef94dbb83f5e670379e1d3e435bd993

See more details on using hashes here.

File details

Details for the file secgen-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: secgen-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for secgen-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0539aaba9cfef31155b6b47c1b11cc7ad89c701d87c57d2adf2435d57c298387
MD5 4791eaabbc6d219febbe15619326dc21
BLAKE2b-256 94266f7dac9e1fa9a6f2de3b3314f9178035533d342a7d85ec4750db5563fc83

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