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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycypherlib-1.3.7.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.7.tar.gz
Algorithm Hash digest
SHA256 7f26974a1c73de317bafd211e3bc5b71c45a1c7509732658233408aa0484beec
MD5 234c68990910ba6d9a3811eb2e6733a8
BLAKE2b-256 60ccd82011e003d3a5aa96b1c900f601249e9d5b026cc573bf41707548a1d8ac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycypherlib-1.3.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e26cabcf387d86855d6262d2a7d130cc1c197671ce7eff366d80e41f7cfef254
MD5 6e184719c22904bebf880fa18d025f36
BLAKE2b-256 2ac8cfbc7666cccc392255cbc5a938225bd9f6289b722be96d3775193c0e1469

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