Skip to main content

DJANGO OUTBOX ENCRYPTION

Project description

DJANGO OUTBOX ENCRYPTION

Sometimes, when you ready to publish your project to server.

There is a slight change between the application settings on the local and the server. Such as database name, password, etc. The second thing, is you need to encrypt information like password or other. The last one, you need to automatically select setting local when you work on local computer, and auto select server when application running on server.

You are on the right path...

Install package to your environment

> pip install outbox-encryption

How to use

Encrypt to environment

This code for create ".env.client" or ".env.server" file    
> python manage.py shell

> from encryption import OutboxEncryption
> lib = OutboxEncryption()
> mplaint_text = {
        'DB_PASSWORD': '',
        'SECRET_KEY': 'xxg_7me8rl2m#a_h2oresgt2#ni=3_4*!ai*=rtsq)yi!g7_5-51xx'
    }
> lib.encrypt_environ('.env.local', mplaint_text)
# file .env.local is created (maybe file is hidden, CTRL+H to show it)

Decrypt from environment

Run inside settings.py (django project settings)            
> from encryption import OutboxEncryption
> lib = OutboxEncryption()

Setting unique variable that only exists in local environment, and not exist in server 
We choose env_outbox_encrypt
> lib.set_keyword_local('env_outbox_encrypt')

List of key variable that must be encrypt or decrypt before set or get data
> mplaint_key = ['DB_PASSWORD', 'SECRET_KEY']

Variable that must be cast as list from environmnet to settings.py
> mplaint_list = ['ALLOWED_HOSTS']

Variable that must be cast as tuple from environment to settings.py
> mplaint_tuple = ['SECURE_PROXY_SSL_HEADER']

Get encryption data
> dict1 = lib.decrypt_environ(mplaint_key, mplaint_list, mplaint_tuple)

Setting variable :
> DEBUG = dict1['DEBUG']
> UNDER_CONSTRUCTION = dict1['UNDER_CONSTRUCTION']
> DEBUG = dict1['DEBUG']
> SECRET_KEY = dict1['SECRET_KEY']
> ALLOWED_HOSTS = dict1['ALLOWED_HOSTS']
> DATABASES = {
    'default': {
        'ENGINE'    : dict1['DB_ENGINE'],
        'NAME'      : dict1['DB_NAME'],
        'USER'      : dict1['DB_USER'],
        'PASSWORD'  : dict1['DB_PASSWORD'],
        'HOST'      : dict1['DB_HOSTS'],
        'PORT'      : dict1['DB_POST'],
    }
> SECURE_PROXY_SSL_HEADER = dict1['SECURE_PROXY_SSL_HEADER']

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

outbox-encryption-1.0.4.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

outbox_encryption-1.0.4-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file outbox-encryption-1.0.4.tar.gz.

File metadata

  • Download URL: outbox-encryption-1.0.4.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for outbox-encryption-1.0.4.tar.gz
Algorithm Hash digest
SHA256 375f6573be6f216f42aba9837755db50461c62e29fd193115f34cccfbc60b703
MD5 46b732e04600000ed9ba61177d01a2ee
BLAKE2b-256 557fe2b10f85e90ae2e13c244af3c29a0614e2261c6f70482aa79cdb655d4602

See more details on using hashes here.

Provenance

File details

Details for the file outbox_encryption-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for outbox_encryption-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d9c19c7ff8a2e051e43d03ee88929dbdf59d50fcc64185e26376d5dbfefef0c1
MD5 17d2eea554900857d8cfdf4376de876a
BLAKE2b-256 6e531677a0933029b6b1ef08d0cb3a10c08e1d4bb5e3a7f8318d6fe60f9f72b9

See more details on using hashes here.

Provenance

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