Skip to main content

Made with Python

license Python Supported Version PyPi Package

EZ Crypt Tool for Python

Create and used encryption keys to encrypt any sensitive information used for your application. Can be used by command line, in environment variables, within Python code as a module. Simplies the process and makes it easy to kep sensative information safe.

Operations


Install

pip install ez-crypt-tool

USE

ez_crypt_tool
Option Description
--genkey Generates a key, that can be used for encryption and decryption.
--genkeyfile Will generate a key and put it in the DEFAULT_KEY_FILE: ~/.ezcrypt/.ezcrypt.key.
--keyfile: Is supplied, will be used for Fernet key.
--encrypt: Uses the key in the KEY_FILES to encrypt a clear text string.
--decrypt Uses the key in the KEY_FILES to decrypt a cipher string.

KEY_FILES: ['.ezcrypt.key', './conf/.ezcrypt.key', '~/.ezcrypt/.ezcrypt.key'] ENV: Environment can be used, skipping key file. Example: export EZCRYPT_KEY=

Step 1: Generate Key or Key File

ez_crypt_tool --genkey
NQYiJixqOhkFWOESyttUvP4ChIcNehpTiyXMGA0eifA=

or

ez_crypt_tool --genkeyfile
NQYiJixqOhkFWOESyttUvP4ChIcNehpTiyXMGA0eifA=

Step 2: Place key in file

Place the key into the ezcrypt.key file, then put the file in one of the 3 locations listed above in KEY_FILES.

Step 3: Use command to encrypt password

ez_crypt_tool --encrypt mypassword
Encrypted:gAAAAABi6DbHCEwLiKHIrolX_oUGA9k-3RjB08-5VW0-lg4FdvGgsiwe1HriMkhLfWRFnMJsbJRvmpULEHbu2Q_EQbFDWaPBxA==

Step 4: Store encrypted password

Place encrypted password in configuration file that can be retrieved by the application.

See example under ./sandbox directory.

Notes

  • A prefix of "fenc:" can be prepended to key, to denote encrypted string. Not required.
  • This project uses an example example test key.
  • The key file [.ezcrypt.key] is in the conf directory.
  • Its only for this example and can be used by others to decyrpt your informaiton.

!!! DO NOT REUSE THE INCLUDED KEY !!! GENERATE A NEW KEY BEFORE USING EzCryptTool in your environment

Prerequisites (IMPORTANT)

  • Python 3.8.x or greater

  • PIP 20.x or greater

  • virtualenv 20.14.x or greater

Code Examples

EzCryptTool Python Code


# Import EzCrypt
from ez_crypt_tool.ez_crypt_tool import EzCryptTool

# Initialize the EzCryptTool
ezc = EzCryptTool.get_instance()

# Starting with clear text string
clear_text_pw = "MyCoolPassword"
print(f"Clear Text: {clear_text_pw}")

# Encrypting the string
crypted_password = ezc.encrypt(clear_text_pw)
print(f"Encrypted: {password}")

# decrypting the string
clear_text_pw = ezc.decrypt(crypted_password)
print(f"Decrypted: {clear_text_pw}")

Output

Clear Text: MyCoolPassword
Encrypted: fenc:gAAAAABjk4vdeenLsvEp_WXKCD_pw2a0oNaSI11l-5WLIdAJH4X579N8GOyYHefEPeR03yJymwoViqba9jBWucKHc4ffoev7Eyyn3O7wx3LmyUqRznut8Cw=
Decrypted: MyCoolPassword

Info and History


History

  • Initial upload

TODO

  • Add generate encryption file
  • Add code examples in readme

Author

License

Copyright © 2023, damonb123. Released under the APACHE-2.0.

Powers by Coffee

Release files for ez-crypt-tool 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ez-crypt-tool 1.0.6
File Size Uploaded
ez_crypt_tool-1.0.6.tar.gz 11.9 kB Details

Release files / ez_crypt_tool-1.0.6.tar.gz

Download URL ez_crypt_tool-1.0.6.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a4cad2f6ad20710b67edda0c7fbc63d165c0bba4e1a941817dcb6f1a86f0e43c
BLAKE2b-256 checksum
How to use checksums
6e140f021944a597e17e11f965dc1545eca786e29cc4d1f45bb44bdc8319596b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

1.0.6 This release

1 release file

1.0.5

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page