module hackathon.crypt_helper

Short summary

module ensae_projects.hackathon.crypt_helper

Encrypting, decrypting.

source on GitHub

Functions

function truncated documentation
_default_name Returns a default username.
get_password Retrieves a password assocatied to key. Relies on module keyring.
set_password Stores a password assocatied to key. Relies on module keyring.

Documentation

Encrypting, decrypting.

source on GitHub

ensae_projects.hackathon.crypt_helper._default_name()[source]

Returns a default username.

os.environ.get('USERNAME', os.environ.get('NAME', 'unknown'))

source on GitHub

ensae_projects.hackathon.crypt_helper.get_password(key, username=None)[source]

Retrieves a password assocatied to key. Relies on module keyring.

Parameters:
  • key – key
  • username – username or environ['USERNAME'] if None
Returns:

password

Store and retrieve a password

Module keyring can be used to store and retrieve a password. It is an easy way to avoid letting clear password in the code. To store a password:

<<<

import keyring
keyring.set_password("system", "username", "password")

>>>

    

And to retrieve it:

<<<

import keyring
pwd = keyring.get_password("system", "username")
print(pwd)

>>>

    password

source on GitHub

ensae_projects.hackathon.crypt_helper.set_password(pwd, key, username=None)[source]

Stores a password assocatied to key. Relies on module keyring.

Parameters:
  • pwd – password
  • key – key
  • username – username or environ['USERNAME'] if None
Returns:

password

source on GitHub