apikeyper.crypt package

Submodules

apikeyper.crypt.encryption_key module

Filename: encryption_key Author: tayja Date: 8/3/2023 Description:

class apikeyper.crypt.encryption_key.EncryptionKey(storage_method, key_file=None, sftp_details=None)[source]

Bases: object

A class that represents an encryption key. This class supports multiple storage methods.

export_to_file(key_file)[source]

Export the encryption key to a file.

Parameters:

key_file (str) – The path to the file that will store the exported key.

export_to_keyring()[source]

Export the encryption key to the system’s keyring.

export_to_sftp(sftp_details)[source]

Export the encryption key to an SFTP server.

Parameters:

sftp_details (dict) – A dictionary containing the connection details for the SFTP server.

apikeyper.crypt.encryption_key.get_key_from_file(key_file)[source]

Retrieve the encryption key from a file. If the file doesn’t exist, generate a new key and save it to the file.

Parameters:

key_file (str) – Path to the file storing the encryption key.

Returns:

The encryption key.

Return type:

bytes

apikeyper.crypt.encryption_key.get_key_from_keyring()[source]

Retrieve the encryption key from the system’s keyring. If it’s not found, generate a new key and save it.

Returns:

The encryption key.

Return type:

bytes

apikeyper.crypt.encryption_key.get_key_from_sftp(sftp_details)[source]

Retrieve the encryption key from an SFTP server.

Parameters:

sftp_details (dict) – A dictionary containing the connection details for the SFTP server.

Returns:

The encryption key.

Return type:

bytes

Module contents

Project: APIKeyPER Author: Inspyre Softworks - https://inspyre.tech Created: 5/21/2023 @ 10:24 PM File:

Name: __init__.py Filepath: apikeyper/crypt

class apikeyper.crypt.CryptDB(file_path=None, encryption_key=None)[source]

Bases: object

A class that represents an encrypted database. This database supports encryption using Fernet symmetric encryption.

decrypt(encrypted_message)[source]

Decrypt an encrypted message using the Fernet symmetric encryption.

Parameters:

encrypted_message (bytes) – The encrypted message to be decrypted.

Returns:

The decrypted message.

Return type:

str

delete()[source]

Delete the encrypted database file.

encrypt(message)[source]

Encrypt a message using the Fernet symmetric encryption.

Parameters:

message (str) – The message to be encrypted.

Returns:

The encrypted message.

Return type:

bytes

export(export_path)[source]

Export the decrypted database data to a JSON or XML file.

Parameters:

export_path (str) – The path to the file where the decrypted data will be exported.

load()[source]

Load the database state from the encrypted file.

Returns:

The decrypted and deserialized database data.

Return type:

dict

move(new_path)[source]

Move the encrypted database file to a new location.

Parameters:

new_path (str) – The path to the new location.

save()[source]

Save the current database state to the encrypted file.