Introduction
- Code monger is a simple Python package for generation and validation of authentication codes which are generated and stored in files .
- For example , you can use this package when generating authentication codes for authenticating user email addresses in a web application .
- NOTE : There are no duplicates in code generation ie, every time a new code is requested the old one is deleted
- Check out the Release notes to stay updated .
- Ideas are welcome, contribute !!
Installation using pip
- You can install the package easily on the command using pip
Dependencies
- Oh , none need installing ,every dependency comes with python ( Python Standard Library )
- The main libraries used are :
- string
- random
- os
Windows OS installation
python3 -m pip install code_monger
alternatively
pip install code_monger
or
py -m pip install code_monger
To upgrade your version in Windows ,just use the --upgrade option when installing . Like so :
python -m pip install --upgrade code_monger
Usage
Simple code generation
- Let us generate a simple code based on the provided parameters
from code_monger import generate_code
# generates the code and returns it as a string object
my_code = generate_code(length = 20 )
print("Code generated : ", my_code)
Custom code generation
- Let us generate a custom code
from code_monger import generate_code
# A code comprising of numbers only
numbers_only = generate_code(numbers = True , letters = False)
# Letters only code
letters_only = generate_code(numbers = False , letters = True )
# Uppercase Letters only code
uppercase_letters_only = generate_code(casing = "upper" , letters = True )
# Lowercase Letters only code
lowercase_letters_only = generate_code(casing = "lower" , letters = True )
# code made up of letters, numbers and punctuation charachters
all_types_of_charachters = generate_code(numbers = True , letters = True , punctuation_chars = True)
Please NOTE : generate_code function and CodeGenerator.NewCode method require the same keyword arguments with the exception that CodeGeneratorNewCode requires the key_string argument
Code generation and validation in files
- The class CodeGenerator is what we will use for this functionality
from code_monger import CodeGenerator
# specify the path you want to store the codes
# If the path doesnt exist , the program will attempt to make it
# Let's replicate a scenario where you want to authenticate a user's email in a web app
user_email = "somerandom@email.com"
codes_file = "codes/my_codes.txt"
cg = CodeGenerator(storage_file = codes_file)
# let us generate a new code and store it in this variable ,
# the code is automatically saved in the file provided during initialization of CodeGenerator
code = cg.NewCode(key_string = user_email )
# validation can be done through the CodeGenerator.ValidateCode method like so:
cg.ValidateCode(user_email , code)
# will return a Boolean , True if the code is valid else False
More on the CodeGenerator class
from code_monger import CodeGenerator
email= "myemail@domain.com"
cg = CodeGenerator("test_codes/example.txt")
# Create a new code for the email
code = cg.NewCode(email)
# delete the code and the email using the code
cg.DeleteCode(code)
# delete the code and the email using the email/key
cg.DeleteKey(email)
# get the code
cg.GetCode(email)
# get the key/email
cg.GetKey(code)
# replace the email/key string
cg.ReplaceKey(email , "mewemail.dom.com")
Metadata
Release files for code-monger 0.2.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| code_monger-0.2.6.tar.gz | 8.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| code_monger-0.2.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.7 kB
Release files / code_monger-0.2.6.tar.gz
| Download URL | code_monger-0.2.6.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
697d9d9cad5401b196dea820793870cc1079607bf2e1cf9b3c0c21a5f2c067bf
|
|
BLAKE2b-256 checksum How to use checksums |
911b17568dfa00af2530a205a8bc9a41eb5048bde675ee626ffcccf62b0a5f2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / code_monger-0.2.6-py3-none-any.whl
| Download URL | code_monger-0.2.6-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
afb0a80f641e379136e7a21599eab00f86def9f05612fbc088a1d029335ec1e4
|
|
BLAKE2b-256 checksum How to use checksums |
c5585c4cfb5c4141ff2a9d88c84cbdc58c17e6e13d9b44aa5f93d9a780d36249
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for code-monger 0.2.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.