Skip to main content

The EntX encryption library for python.

Project description

EntX - The Python Encryption Library

EntX Encryption and Decryption

Note: EntX Encryption will store all keys and values as strings. If you plan on running operations on integers/floars in your data, convert them with int() or float() before use.

How to create an encryption client with password stored in an environment variable:

import os
import entx

client = entx.Client(os.environ["password"])

How to encrypt a string

import os
import entx

client = entx.Client(os.environ["password"])
to_encrypt = "This will be encrypted"
encrypted = client.encrypt(to_encrypt)

How to decrypt a string

import os
import entx

client = entx.Client(os.environ["password"])
to_decrypt = "This will be decrypted"
encrypted = client.decrypt(to_decrypt)

EntX Storage

JSON

EntX supports JSON reading and writing, allowing you to store and read dictionaries in the .json format, automatically encrypting and decrypting the data with the password provided.

To store values as a JSON with encryption only applying to the values, pass in the keyword parameter encrypt_output = False to the dumps and dump functions. If this is not passed or set to True, the json will be encrypted before writing and only readable using the EntX JSONClient.

To read values from a JSON with encryption only applying to the values, pass in the keyword parameter encrypted_input = False to the load and loads functions. If this is not passed or set to True, the client will attempt to decrypt the json before converting it to an object, throwing an error if the json is not encrypted or the password provided is incorrect.

It is recommended that you encrypt your output json to increase the strength of the output's encryption.

How to create a JSON client with a password stored in an environment variable:

import os
from entx.storage import JSONClient

client = JSONClient(os.environ["password"])

How to convert a dictionary to an encrypted JSON string:

import os
from entx.storage import JSONClient

client = JSONClient(os.environ["password"])
to_encrypt_dictionary = {"keys": "values"}
dictionary_json_string = client.dumps(to_encrypt_dictionary)

How to write a dictionary to an encrypted JSON file:

import os
from entx.storage import JSONClient

client = JSONClient(os.environ["password"])
to_encrypt_dictionary = {"keys": "values"}
with open("demo.json", "w") as output_file:
    client.dump(to_encrypt_dictionary, output_file)

How to read a dictionary from an encrypted JSON string:

import os
from entx.storage import JSONClient

client = JSONClient(os.environ["password"])
encrypted_json_string = "your string here"
decrypted_dictionary = client.loads(encrypted_json_string)

How to read a dictionary from an encrypted JSON file:

import os
from entx.storage import JSONClient

client = JSONClient(os.environ["password"])
with open("demo.json", "r") as input_file:
    decrypted_dictionary = client.load(input_file)

EntX Storage Exceptions:

entx.errors.InvalidPasswordException

Raised when the password provided for a client file is invalid. Often raised when trying to load from a file with an incorrect password.

EntX Users

EntX User Management System

As of Version 3.0.0, EntX now comes with the users module to manager users and their data. All user files are encrypted using the user password, and can be stored in any relative directory.

How to create a new user in a "users" folder:

from entx.users import User
user = User.new_user("username", "password", "users")

How to log in to an existing user in a "users" folder:

from entx.users import User
user = User.login("username", "password", "users")

How to access a user's data object from a User object:

from entx.users import User
user = User.login("username", "password", "users")
data = user.obj
print(data)

How to add a field to a user's data object and save it to the user's file:

from entx.users import User
user = User.login("username", "password", "users")
user.obj["new_field"] = "field contents"
user.update()

User Management Exceptions:

entx.errors.UserAlreadyExists

Raised when you are trying to create a new user in a directory where a user with that username already exists.

entx.errors.InvalidUser

Raised when you are trying to log in to a user that doesn't exist.'

entx.errors.InvalidPasswordException

Raised when the password provided for a user is invalid.

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

entx-3.0.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

entx-3.0.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file entx-3.0.1.tar.gz.

File metadata

  • Download URL: entx-3.0.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for entx-3.0.1.tar.gz
Algorithm Hash digest
SHA256 2bbf2a73d9128e4af677fa5d80a1f895429b9fc5a1256080309462bb540844b7
MD5 662e1f0bc71cddddded0f197c2e5fada
BLAKE2b-256 41a8446a0dcf053c97d0132a767211f1c351f553290dbbc7ebc86f902f910ba7

See more details on using hashes here.

File details

Details for the file entx-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: entx-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.0

File hashes

Hashes for entx-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2ac9e0e6694bcbea146a2419cfc45daa9e6fe0c78789db04998a7d9d87ce6ec9
MD5 46e3adc08e91531a4071f4e3f6bdf429
BLAKE2b-256 ba5cd66a9aeedb7000c77f3f778861ef60ff1baad1c2d0dba199ad14cddc8ee8

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