Skip to main content

Encrypt credentials/Django settings to store in repositories

Project description

PyPI version

encrypted-credentials encrypts credentials to allow them to be securely added to git repositories.

It can import encrypted settings into Django defined in a python module and or a json file. Encrypted files are automatically generated.

Django settings


File stored in folder with django file

private_settings = {


File stored in folder with django file


from encrypted_credentials.django_credentials import add_encrypted_settings


Upon first execution a PRIVATE_KEY.env file will be generated with a random encryption key. DO NOT check this into repository. if does not exist it will generate a template module.

set environment variable

  1. If the settings.json file exists and settings.json.enc does not exist then settings.json.enc will be created.(development)
  2. If settings.json and settings.json.enc exist then they will be compared and if different settings.json.enc will be overwritten.(development)
  3. If settings.json does not exist then settings.json.enc will be used (production)

settings.json.enc and or PRIVATE_settings.enc can be checked into git as it is encrypted with Fernet AES128 encryption

Credential files

get_decrypted_file will automatically encrypt the original file and supply the decrypted data

from encrypted_credentials.encrypted_file import get_decrypted_file


original.pem.enc can be checked into a repository

Credential files with Django

By default environment variable SETTINGS_KEY will be used as key

CREDENTIAL_FOLDER = os.path.join(BASE_DIR, 'credentials')
    'gmail': 'service-account-abcd.json',
    'drive': 'service-account-efgh.json',



from encrypted_credentials.django_credentials import get_credentials

credentials = get_credentials('gmail')

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

encrypted-credentials-0.0.4.tar.gz (4.1 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page