Easily encrypt & decrypt files with python / through the CLI.


Keywords
cli, decrypt, decrypting, encrypt, encrypti0n, encrypting, encryption, encryption-decryption, python3
License
MIT
Install
pip install encrypti0n==3.22.4

Documentation

encrypti0n

Author(s): Daan van den Bergh.
Copyright: © 2020 Daan van den Bergh All Rights Reserved.
Supported Operating Systems: macos & linux.


Bergh-Encryption

Table of content:

Description:

Python & cli encryption toolset.

Installation:

Install the package.

pip3 install encrypti0n --upgrade && python3 -c "import encrypti0n" --create-alias encrypti0n

CLI Usage:

Usage: encrypti0n <mode> <options> 
Modes:
    --encrypt /path/to/input /path/to/output : Encrypt the provided file path.
    --decrypt /path/to/input /path/to/output : Decrypt the provided file path.
    --generate-keys : Generate a key pair.
    --generate-passphrase --length 32 : Generate a passphrase.
    -h / --help : Show the documentation.
Options:
    --remove : Remove the input file.
    --key /path/to/directory/ : Specify the path to the key's directory.
    --public-key /path/to/directory/public_key : Specify the path to the public key.
    --private-key /path/to/directory/private_key : Specify the path to the private key.
    -p / --passphrase 'Passphrase123!' : Specify the key's passphrase.
Author: Daan van den Bergh. 
Copyright: © Daan van den Bergh 2021. All rights reserved.
Usage at own risk.

Code Examples:

Table of content:

AES:

The aes object class.

# initialize the aes object class.
aes = AES(passphrase=None)

Functions:

encrypt:
# call aes.encrypt.
response = aes.encrypt(raw)
decrypt:
# call aes.decrypt.
response = aes.decrypt(enc)
get_key:
# call aes.get_key.
response = aes.get_key(salt=None)
generate_salt:
# call aes.generate_salt.
response = aes.generate_salt()

Agent:

The agent object class.

# initialize the agent object class.
agent = Agent(
    # the encryption & webserver's id.
    id="encrypti0n-agent",
    # the configuration file (Dictionary).
    config=Dictionary,
    # the path to the encrypted database.
    database=Directory,
    # the passphrase (optional to prompt) (str).
    passphrase=None,
    # the interactive mode (prompt for password) (bool).
    interactive=True,
    # the webserver's host.
    host="127.0.0.1",
    # the webserver's port.
    port=52379,
    # the object traceback.
    traceback="encryption.Agent", )

Functions:

generate:
# call agent.generate.
response = agent.generate(
    # the passphrase (optional to prompt) (str).
    passphrase=None,
    # the verify passphrase (optional).
    verify_passphrase=None,
    # interactive (optional).
    interactive=None )
activate:
# call agent.activate.
response = agent.activate(
    # the key's passphrase (optional to retrieve from webserver) (str).
    passphrase=None,
    # interactive (optional)
    interactive=None, )
encrypt:
# call agent.encrypt.
_ = agent.encrypt(string, decode=False)
decrypt:
# call agent.decrypt.
_ = agent.decrypt(string, decode=False)

Properties:

# the activated property.
activated = agent.activated
# the public key activated property.
public_key_activated = agent.public_key_activated
# the private key activated property.
private_key_activated = agent.private_key_activated
# the generated property.
generated = agent.generated

AsymmetricAES:

The asymmetricaes object class.

# initialize the asymmetricaes object class.
asymmetricaes = AsymmetricAES(
    # the public key (str).
    public_key=None,
    # the private key (str).
    private_key=None,
    # the key passphrase (str / null).
    passphrase=None,
    # enable memory when the keys are not saved.
    memory=False, )

Functions:

generate_keys:
# call asymmetricaes.generate_keys.
_ = asymmetricaes.generate_keys()
edit_passphrase:
# call asymmetricaes.edit_passphrase.
_ = asymmetricaes.edit_passphrase(passphrase=None)
load_keys:
# call asymmetricaes.load_keys.
_ = asymmetricaes.load_keys()
load_private_key:
# call asymmetricaes.load_private_key.
_ = asymmetricaes.load_private_key()
load_public_key:
# call asymmetricaes.load_public_key.
_ = asymmetricaes.load_public_key()
encrypt:
# call asymmetricaes.encrypt.
response = asymmetricaes.encrypt(string, decode=False)
decrypt:
# call asymmetricaes.decrypt.
response = asymmetricaes.decrypt(string, decode=False)
encrypt_file:
# call asymmetricaes.encrypt_file.
response = asymmetricaes.encrypt_file(input=None, output=None, remove=False, base64_encoding=False)
decrypt_file:
# call asymmetricaes.decrypt_file.
response = asymmetricaes.decrypt_file(input=None, output=None, remove=False, base64_encoding=False)
encrypt_directory:
# call asymmetricaes.encrypt_directory.
response = asymmetricaes.encrypt_directory(input=None, output=None, remove=False)
decrypt_directory:
# call asymmetricaes.decrypt_directory.
response = asymmetricaes.decrypt_directory(input=None, output=None, remove=False)

Properties:

# the activated property.
activated = asymmetricaes.activated
# the public key activated property.
public_key_activated = asymmetricaes.public_key_activated
# the private key activated property.
private_key_activated = asymmetricaes.private_key_activated

Database:

The database object class.

# initialize the database object class.
database = Database(
    # the aes object class.
    aes=None,
    # the root path of the database.
    path=None, )

Functions:

activate:
# call database.activate.
response = database.activate(
    # the key;s passphrase (optional).
    passphrase=None, )
check:
# call database.check.
response = database.check(
    # the subpath of the content (! param number 1).
    path=None,
    # the default content data (! param number 2).
    default=None,
    # save the changes.
    save=True, )
load:
# call database.load.
response = database.load(
    # the subpath of the content (! param number 1).
    path=None,
    # the default data, specify to call database.check() automatically on the data object.
    default=None, )
save:
# call database.save.
response = database.save(
    # the content object (! param number 1).
    content=None, )

Properties:

# the activated property.
activated = database.activated
# the public key activated property.
public_key_activated = database.public_key_activated
# the private key activated property.
private_key_activated = database.private_key_activated

RSA:

The rsa object class.

# initialize the rsa object class.
rsa = RSA(
    # option 1:
    #     the key directory.
    directory=None,
    # option 2:
    public_key=None,
    private_key=None,
    memory=False, # enable memory when the keys are not saved.
    # the key's passphrase (Leave None for no passphrase).
    passphrase=None, )

Functions:

generate_keys:
# call rsa.generate_keys.
response = rsa.generate_keys(log_level=0)
load_keys:
# call rsa.load_keys.
response = rsa.load_keys()
load_public_key:
# call rsa.load_public_key.
response = rsa.load_public_key()
load_private_key:
# call rsa.load_private_key.
response = rsa.load_private_key()
edit_passphrase:
# call rsa.edit_passphrase.
_ = rsa.edit_passphrase(passphrase=None)
encrypt_string:
# call rsa.encrypt_string.
response = rsa.encrypt_string(string, layers=1, decode=True)
encrypt_file:
# call rsa.encrypt_file.
response = rsa.encrypt_file(path, layers=1)
encrypt_directory:
# call rsa.encrypt_directory.
response = rsa.encrypt_directory(path, recursive=False, layers=1)
decrypt_string:
# call rsa.decrypt_string.
response = rsa.decrypt_string(string, layers=1, decode=True)
decrypt_file:
# call rsa.decrypt_file.
response = rsa.decrypt_file(path, layers=1)
decrypt_directory:
# call rsa.decrypt_directory.
response = rsa.decrypt_directory(path, recursive=False, layers=1)

Properties:

# the activated property.
activated = rsa.activated
# the private key activated property.
private_key_activated = rsa.private_key_activated
# the public key activated property.
public_key_activated = rsa.public_key_activated