Skip to main content

Secure file encryption and decryption library with fluent API

Project description

PyCypher

PyCypher is a Python library based on the library cryptography that provides secure encryption and decryption of files and strings, plus an optional decrypt&execute option 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

# Base methods for encryption and decryption ations
# using the .P() method to type the password manually
Cy().enc("file.txt").P("yourpassword")
Cy().dec("file.txt.cy").P("yourpassword")

# With rhe .run() method you can 'decrypt&run' an encrypted python scrypt
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 .newNme() 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')

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

pycypherlib-1.3.8.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

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

pycypherlib-1.3.8-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file pycypherlib-1.3.8.tar.gz.

File metadata

  • Download URL: pycypherlib-1.3.8.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pycypherlib-1.3.8.tar.gz
Algorithm Hash digest
SHA256 6ea726a7d635f890748575129b910d2f460654b5c02bf90a10a3efbe4fc5bfa6
MD5 bd9ca0629313a21e6212adb22e851c06
BLAKE2b-256 b429f23257f1c56f81d32b92a07cbe3f401174933a2e51a618266b71f989e4a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycypherlib-1.3.8.tar.gz:

Publisher: publish.yml on eaannist/PyCypher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycypherlib-1.3.8-py3-none-any.whl.

File metadata

  • Download URL: pycypherlib-1.3.8-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pycypherlib-1.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 db829b91cbd5ccb625904c50fb930bd28d4beefaeb6f4ba03b01dba864312705
MD5 5710ea498320e43c66b8b100d23c125c
BLAKE2b-256 5b3e3c228e7c6ff8dad0c5e55912585a8f58498aea83e4a92576ec6b9345522a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycypherlib-1.3.8-py3-none-any.whl:

Publisher: publish.yml on eaannist/PyCypher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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