Skip to main content

A password attribute that stores hashes

Project description

The password module offers you a single utility class called Password. This class is meant to be used as an attribute of any other object class on which you want to store passwords in hashed mode. This module is framework-agnostic so it is up to you to provide persistence (you need to store ‘hash’ and ‘salt’ set on the object).

Example usage

Create your class:

>>> import password
>>> class User():
...     password = password.Password(method='sha1', hash_encoding='base64')
        # You also probably want to create 'hash' and 'salt' attributes
        # With your chosen persistence mechanism

Set a password on the object:

>>> user = User()
>>> user.password = 'abcdef'

You cannot read the password back:

>>> user.password
<password._HashedPassword object at 0x7fdba1fef990>

but you can see, that hash and salt are set:

>>> user.hash
'L1Fz6aoIdIlZzoxsXPWxJq8zNTQ='
>>> user.salt
'VIboVvtr'

You can also check for equality with a string:

>>> user.password == 'abcdef'
True
>>> user.password == '12345'
False

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

password-0.2.zip (3.8 kB view details)

Uploaded Source

password-0.2.tar.bz2 (2.5 kB view details)

Uploaded Source

File details

Details for the file password-0.2.zip.

File metadata

  • Download URL: password-0.2.zip
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for password-0.2.zip
Algorithm Hash digest
SHA256 c1502353c1c5c0541c0625b4f71255eb1b06e72b8146963a08ea3aa340c0bf53
MD5 1990946a4dc63790c277a3e06ea44495
BLAKE2b-256 81a34e83ff416b1d544da276a0a95ce469c0ec7b28f68a68cf61c9a987dda134

See more details on using hashes here.

File details

Details for the file password-0.2.tar.bz2.

File metadata

  • Download URL: password-0.2.tar.bz2
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for password-0.2.tar.bz2
Algorithm Hash digest
SHA256 9ad8ed238c0c3f929778bc82237ecfd333a1b7357b5864bce7d7b5cd2b039b19
MD5 f1391ad79517bf61b3efe671166928e6
BLAKE2b-256 293ebeaeac8ff2c014630ca99ee3ae0d4179c08407f50215aac2377323436b52

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