A completely randomized order of secrets, with security in mind.
Project description
Polysecrets
A completely randomized order of secrets; built with security in mind. Secrets can be automatically generated on a time interval or manually generated. Polysecrets keeps the guessing away from the human in exchange for a truly secret, randomized signing order. Instead of a hardcoded secret that can be stolen during a security breach, Polysecrets, randomizes the provided string in a way that a secret produced at 8:00pm can be completely different from a secret produced at 8:01pm, on the same server.
Libraries - v0.1.4
NodeJS: https://www.npmjs.com/package/polysecrets Python: https://pypi.org/project/polysecrets/
Author
Let's connect on LinkedIn: https://www.linkedin.com/in/jaylen-douglas-292b82a6/
Requirements
- Python 3.5+
- Windows, OSX or Linux
Install
Locally
git clone https://github.com/ableinc/polysecrets.git
cd polysecrets
python -m pip install --upgrade .
or
pip install --upgrade .
PyPi (Pip)
python -m pip install --upgrade polysecrets
or
pip install --upgrade polysecrets
How To Use
Polysecrets can be used manually or automated. Automated use can be provided a time (in seconds) for
how often a new secret should be generated, the default time is set to 30 seconds. You do not have
to provide a secret to Polysecrets class, but you can if you'd like
certain characters in your secret. Reminder, the secret is a collection of
randomly ordered characters so the secret you provide will not be used entirely.
** Look through examples folder **
Automated (this will add the secret to your environment)
from os import environ
from polysecrets import PolySecrets
config = dict(
secret='rAnd0m_s3cr3t', # or use default
length=10, # default
interval=30, # default (only if you're using automated)
uuid='yes', # default
mixcase=False, # default
persist=False, # default
symbols=False
)
automated = PolySecrets(config).automated() # default time is set to 30 seconds
print(environ['secret']) # confirm secret is available
automated.terminate() # stop automation
Manual:
from polysecrets import PolySecrets
config = dict(
secret='rAnd0m_s3cr3t', # or use default
length=10, # default
interval=30, # default (only if you're using automated)
uuid='yes', # default
mixcase=False, # default
persist=False, # default
symbols=False
)
secret = PolySecrets(config).manual()
print(secret) # confirm secret is available
Refer to examples folder for all use cases.
Also refer to 'Notes' section at the bottom of
this README.
If you want your environment variables cleared after Polysecrets
terminates, do the following:
from polysecrets import PolySecrets
from os import environ
config = {} # use all defaults
automated = PolySecrets(config=config, clear_on_exit=True).automated()
print(environ['secret'])
automated.terminate() # forcibly remove envs
Persistence
You can you use the persistence feature to keeps record of the secrets produced, and verifies that no secret has been duplicated. You will need to have a .env file with the MongoDB credentials inside. An example of the .env file is below:
HOST=localhost
#PORT=27017
USER=root
PASS=r00tp@ssw0rD
#DB_NAME=polysecrets
#COLLECTION=secrets
#AUTH_SOURCE=admin
# Host URI Example
HOST=mongodb://user:password@example.com/?authSource=the_database&authMechanism=SCRAM-SHA-1
Notes:
- All variables with the '#' prefix are optional; defaults will be assigned.
- Host variable can also be a full MongoDB URI. If so, it will ignore all other variables.
Options
You can do the following with Polysecrets:
- Manually or Automatically generate new secrets
- Change time interval for new secret generation (for Automated feature)
- Change the length of the final Polysecrets secret (refer to Notes at end of README)
- Choose whether to generate secrets with just UUIDs, Alphanumeric characters or both
- Persist generated secrets to ensure the same secret isn't used twice
The CLI (below) has full details of each option (except automated option)
CLI
You can use Polysecrets as a command line tool. CLI does not provided automated feature. If secret is left out, it will default to a random string built into the Polysecrets. An example is below:
polysecrets --length 20 go
Help menu
Usage: polysecrets [OPTIONS] GO
Options:
-s, --secret TEXT The secret string
-l, --length INTEGER Length of the secret. Secret has a minimum length of
10
-i, --interval INTEGER How frequently should a new secret be generated (in
seconds)
-u, --uuid TEXT Whether to use UUIDs or Alphanumeric characters for
secret generation - yes, no, both
-m, --mixcase BOOLEAN Decide whether or not to mix the case of
alphacharacters in secret string
-p, --persist DICT Never get the same secret twice with persistence
from MongoDB
--symbols BOOLEAN Whether or not to use special characters in secret.
This will only increase the probability of appending
a special character.
--version Show the version and exit.
--help Show this message and exit.
Benefits
- JSON Web Tokens
- Certificate Signing
- Hashing
- Various scenarios of Cryptography
What's Next
(refer to Changelog)
If you have found a bug or would like to create new features, make a PR!
Changelog
v0.1.4 - June 1st, 2021
- Improved CLI tool
- Fixed persistence bug
- Simplified defaults
v0.1.3 - July 11th, 2019
- Improved code and squashed bugs
v0.1.2 - July 1st, 2019
- Persistence added. You can now avoid duplicate secrets being generated.
- Node version is now available. Install:
npm install polysecrets
- Improved code and squashed bugs
v0.1.1 - June 4th, 2019
- Custom secret string length, with a minimum of 10 characters
- You may mix the secret, in combination with the provided secret string, with UUIDs, alphanumeric characters or both.
- You can now select between upper and lower case mixing during secret generation
v0.1.0 - June 3rd, 2019
- Manually and autogenerated secrets, with fixed secret length
- Polysecrets CLI added
Note
-
If you change the length of the secret via the 'length' parameter, you will notice that the secret string you provided will not contain all the characters provided. If you want the final secret to contain all the exact same characters, then provide the exact string length to Polysecrets 'length' field.
-
The secret provided in the config is just used as reference characters and are not guaranteed to be a part of the final secret. If you would like to use the secret you provide I would recommend going the traditional route; add secret to your project .env file and use Able's Py.Envs python library.
-
You cannot run manual and automated in the same file. You will throw an error.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file polysecrets-0.1.4.tar.gz
.
File metadata
- Download URL: polysecrets-0.1.4.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.5.0.1 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0a9e296f86bf6aad0fa550e19b2d881c971afc0ea0ba03401ace69c7b158b3f |
|
MD5 | ef6b17f43fbf07dd18ec7ae349615d32 |
|
BLAKE2b-256 | 18f81c1ce57bbcd400a06cd86f42cb8dcdc33c4136972ea5404feb4118c48133 |
File details
Details for the file polysecrets-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: polysecrets-0.1.4-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.5.0.1 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c9352849d54c96b0a2f71d9c07d6a5c96d661f5e2fffef6fcf476d72d6e3ab7 |
|
MD5 | e61225a3b5e7935442b003159fe4216b |
|
BLAKE2b-256 | 41da7733c26d16ef8120caf6dca0d93e1e25d2e156ad45e325f530b24c68e96c |