Secure file encryption and decryption library with fluent API
Project description
PyCypher
PyCypher is a Python library based on the libraries cryptography and argon2 that provides secure encryption and decryption, plus an optional decrypt&execute feature for encrypted Python scripts. It attempts to securely wipe in-memory data and input files (on a best-effort basis, not guaranteed on all systems).
Installation
pip install PyCypherLib
Usage
# Import the PyCypher library:
from PyCypher import Cy
# KDF Selection:
# Cy() - Default: Argon2 (recommended for maximum security)
# Cy("A") - Explicit: Argon2
# Cy("P") - Explicit: PBKDF2
# All modes support auto-detection of encrypted file formats
# Base methods for encryption and decryption operations
# using the .P() method to type the password manually
Cy().enc("file.txt").P("yourpassword")
Cy().dec("file.txt.cy").P("yourpassword")
# With the .run() method you can 'decrypt&run' an encrypted python script
Cy().run("file.py.cy").P("yourpassword")
# By default the encrypted file is saved with the .cy extension added to the input file name
Cy().dec("file.txt.cy").P("yourpassword")
# Use the .newName() method to specify the output file name
Cy().enc("file.txt").newName("file.enc").P("yourpassword")
# Use the .delInput() method to automatically delete the input file
Cy().enc("file.txt").newName("file.cy").delInput().P("mypassword")
Cy().dec("file.cy").newName("file.txt").delInput().P("mypassword")
# Use the .toData() method to get encrypted/decrypted data instead of writing to file
encrypted_data = Cy().enc("file.txt").toData().P("yourpassword")
decrypted_data = Cy().dec("file.txt.cy").delInput().toData().P("yourpassword")
# Use the .terminalP() method to insert the password in the terminal with your own message
Cy().dec("file.enc").newName("file.txt").delInput().terminalP("Please enter password: ")
# Use the .encLines() and Lines() methods to encrypt a single string or a list of strings
# the default output file will be cyfile.cy
Cy().encLines().Lines('yoursecretkey').P('yourpassword')
Cy().encLines().Lines(['yoursecretkey', 'yoursecrettoken']).P('yourpassword')
# Use one or more .terminalL() methods to add lines to encrypt by terminal
# and you can specify an output file name as .encLines() argument
Cy().encLines('credentials.cy')\
.terminalL('Enter your secret key: ')\
.terminalL('Enter your secret token: ')\
.terminalP('Enter a password to encrypt your credentials: ')
# Use the .decLines() method to decrypt the encrypted string or strings
# it will return a string or a list of strings
key = Cy().decLines('key.cy').terminalP('Enter a password to access your secret key: ')
key,token = Cy().decLines('credentials.cy').terminalP('Enter a password to access your credentials: ')
# Use the .changeP() and .newP() methods to change the encryption password of an encrypted file
Cy().changeP('credentials.cy').newP('newpassword').P('oldpassword')
# Examples with explicit KDF selection:
Cy("A").enc("sensitive.txt").P("strongpassword") # Force Argon2
Cy("P").enc("legacy.txt").P("oldpassword") # Force PBKDF2
Development status
PyCypher is a work-in-progress personal project. Suggestions, feature requests, and constructive feedback are highly welcome. Feel free to open an issue or submit a pull request.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycypherlib-1.4.2.tar.gz.
File metadata
- Download URL: pycypherlib-1.4.2.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
131d2f7d03615e6d33d4f68215ddf3019351f657d3be19eadf1aff995ec20b1e
|
|
| MD5 |
6b84efb2acd27154cb1df42a46c9446d
|
|
| BLAKE2b-256 |
1b1f2f110bf58ed10716f303e9eb909f16d6e3a2306878dfb0e00037e7cb2155
|
Provenance
The following attestation bundles were made for pycypherlib-1.4.2.tar.gz:
Publisher:
publish.yml on eaannist/PyCypher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycypherlib-1.4.2.tar.gz -
Subject digest:
131d2f7d03615e6d33d4f68215ddf3019351f657d3be19eadf1aff995ec20b1e - Sigstore transparency entry: 319298729
- Sigstore integration time:
-
Permalink:
eaannist/PyCypher@2fb7dd12a8f02d2f2b7cc399a31f2a7271f30a1b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/eaannist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2fb7dd12a8f02d2f2b7cc399a31f2a7271f30a1b -
Trigger Event:
push
-
Statement type:
File details
Details for the file pycypherlib-1.4.2-py3-none-any.whl.
File metadata
- Download URL: pycypherlib-1.4.2-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35a46e5a56a23e6b9c322ae019c7bf4d749d81cba3a0adda20bf78926c29942e
|
|
| MD5 |
f4e361d8ea6ae5597fe132fcd0c873e4
|
|
| BLAKE2b-256 |
a084901f1aefcc0f5da3bcfe64a9a6d5a7e3e766c4cdcc50b7fc724a4213de4d
|
Provenance
The following attestation bundles were made for pycypherlib-1.4.2-py3-none-any.whl:
Publisher:
publish.yml on eaannist/PyCypher
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycypherlib-1.4.2-py3-none-any.whl -
Subject digest:
35a46e5a56a23e6b9c322ae019c7bf4d749d81cba3a0adda20bf78926c29942e - Sigstore transparency entry: 319298732
- Sigstore integration time:
-
Permalink:
eaannist/PyCypher@2fb7dd12a8f02d2f2b7cc399a31f2a7271f30a1b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/eaannist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2fb7dd12a8f02d2f2b7cc399a31f2a7271f30a1b -
Trigger Event:
push
-
Statement type: