Skip to main content

Utility to easily store password/secrets.

Project description

Palette Material Design

Build Status codecov

Utility to easily store password/secrets. It uses Fernet from the cryptography module instead of reinventing the wheel.

Fernet is a symmetric encryption that uses 128-bit AES in CBC mode and PKCS7 padding with HMAC using SHA256 for authentication. You can read more about it here.

Why v-crypt?

It is always annoying to deal with secrets and passwords in python especially if you work with other people. What we found that worked best for us was:

  • Create one master private password (ignored from git)
  • Have dict-like file with the rest of passwords encrypted

This module provides the class Cipher to handle that easily.

The idea behind this module is to be able to create a json or yaml with encrypted secrets. The keys will be public but the values won't. This way you can store the dictionary of secrets in git and easily share them with other people working in the same project. You will only need to share the master.password once. And all the other passwords/secrets will be tracked with git.

Installation

You can install it with pip by running:

pip install v-crypt

Usage

from v_crypt import Cipher

# Create a cipher instance
cipher = Cipher()

# Create a new master password
cipher.create_password()

# Store a secret
cipher.save_secret("secret", "I like python")

# Retrive a secret
cipher.get_secret("secret")

Customization

There are three paramaters to customize the cipher:

  1. secrets_file: path of the file with secrets. Can be a json or yaml.
  2. filename_master_password: path of the file with the master password
  3. environ_var_name: if passed it allows to read the master password from an environ var.

For yaml you need to install pyyaml

For example you could do:

cipher = Cipher(secrets_file="data/secrets.yaml", filename_master_password="data/master.secret")

This will allow you to store both the master.password and secrets.yaml in the folder data.

There is not much more customization since the idea is to keep it simple.

Integrating it in other projects

We usually have one or more python files with utilities, for example utilities.py.

To use v_crypt we initiallize the cipher there and then create a get_secret dummy function that will call the cipher.

from v_crypt import Cipher

cipher = Cipher(secrets_file="data/secrets.yaml", filename_master_password="data/master.secret")

def get_secret(key):
    return cipher.get_secret(key)

Then you can use it elsewhere with:

import utilities as u

u.get_secret("secret")

Authors

License

The content of this repository is licensed under a MIT.

Nomenclature

Branches and commits use some prefixes to keep everything better organized.

Branches

  • f/: features
  • r/: releases
  • h/: hotfixs

Commits

  • [NEW] new features
  • [FIX] fixes
  • [REF] refactors
  • [PYL] pylint improvements
  • [TST] tests

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

v_crypt-1.0.4.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

v_crypt-1.0.4-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file v_crypt-1.0.4.tar.gz.

File metadata

  • Download URL: v_crypt-1.0.4.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for v_crypt-1.0.4.tar.gz
Algorithm Hash digest
SHA256 04a9d81db5903c98a6ac8d99d054a2c8b1349345a1d81b3fe5009ca51045ef04
MD5 e94a308505c27499c434097f9ad2b1a2
BLAKE2b-256 0da469fe3c20dd2ac58c545992117591eced4e4dbb181070ebad9c7cf600c492

See more details on using hashes here.

File details

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

File metadata

  • Download URL: v_crypt-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for v_crypt-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 c817c4f4b6ad43702a54626c511278c514f19a778be059c0bea607a9da5ca736
MD5 1230bb4ff094f9fcf231b67bb8774a8e
BLAKE2b-256 c6cc8dc8a001d02bf1e785fcacbfca13378ebdda40c5764435a724ba49010adf

See more details on using hashes here.

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