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.6.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.6-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pycypherlib-1.3.6.tar.gz
Algorithm Hash digest
SHA256 e8a18b64f24b0adef2c607148ec23d94fc9fb57ef3fd48f7da67283e3dd917cd
MD5 df959c3b3f15a541bd551e141a8e3859
BLAKE2b-256 5032d99b4ee9e1f8f248944a2a760d37b886cf6c391cf6759f70ac4fb46080c7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pycypherlib-1.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 b867ce36317d8384dc6e96ce3ed131d11f081b9907635fd2535de5ab66e1c5df
MD5 c4d7a364222769acca0ff3dd9001e04a
BLAKE2b-256 c9a260f34b5f2da44dc200e8bba769422a9761df57b85940ec59a62b0bb4c44c

See more details on using hashes here.

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