Skip to main content

A package for encrypting files with a password.

Project description

Description

pydlock is a simple Python package for encrypting and decrypting files. It can be used either as a package imported into other Python modules or as a command line script.

Installation

pydlock is available on the Python Package Index (PyPI) at https://pypi.org/project/pydlock. To install pydlock, simply use the Python pip installer:

pip install pydlock

Usage

From the command line

To access the help method of the script, use python -m pydlock -h:

user@computer:~$ python -m pydlock -h
usage: __main__.py [-h] [--arguments ARGUMENTS] [--encoding ENCODING]
                   {lock,unlock,python,run} file

positional arguments:
    {lock,unlock,python,run}
    file

optional arguments:
    -h, --help            show this help message and exit
    --arguments ARGUMENTS
    --encoding ENCODING

To encrypt a file, use python -m pydlock lock [file]:

user@computer:~$ cat secret.txt
Shh! It's a secret!

user@computer:~$ python -m pydlock lock secret.txt
Enter password:
Re-enter password:

user@computer:~$ cat secret.txt
gAAAAABeqx971nHtXHi4dJYw8A_m_1mRYT8V2Sy4XPLqdg0t4mp9ooN-aTU1fuPQwEpwnuFiAfbJ6oPaN9IB1gzFT5-Tb4gFXQMw5uQUXDYV2Pvso6E5lXQ=

To decrypt a file, use python -m pydlock unlock [file]:

user@computer:~$ cat secret.txt
gAAAAABeqx971nHtXHi4dJYw8A_m_1mRYT8V2Sy4XPLqdg0t4mp9ooN-aTU1fuPQwEpwnuFiAfbJ6oPaN9IB1gzFT5-Tb4gFXQMw5uQUXDYV2Pvso6E5lXQ=

user@computer:~$ python -m pydlock unlock secret.txt
Enter password:

user@computer:~$ cat secret.txt
Shh! It's a secret!

To run an encrypted Python file, use python -m pydlock python [file]:

user@computer:~$ cat hello_world.py
print("Hello world!")

user@computer:~$ python -m pydlock lock hello_world.py
Enter password:
Re-enter password:

user@computer:~$ cat hello_world.py
gAAAAABeq6fM4Qxm0TB9cGIg6G-uNprWIAyPmuciugNGIvPxudmBgkIWGhlV3Lg7RyMRdUVODRCehxWXnS5zhSm6fDZ0Ct57XYPztYi_9DZHp0sO1rXuyCE=

user@computer:~$ python -m pydlock python hello_world.py
Enter password:
Hello world!

user@computer:~$ cat hello_world.py
gAAAAABeq6fM4Qxm0TB9cGIg6G-uNprWIAyPmuciugNGIvPxudmBgkIWGhlV3Lg7RyMRdUVODRCehxWXnS5zhSm6fDZ0Ct57XYPztYi_9DZHp0sO1rXuyCE=

In other Python modules

import pydlock

filename = "secret.txt"

with open(filename, "w+") as file:

    print("Shh! It's a secret!", file = file)

pydlock.lock(filename)

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

pydlock-1.2.0.15.tar.gz (6.6 kB view hashes)

Uploaded Source

Built Distribution

pydlock-1.2.0.15-py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page