Introduction
Himitsu is a wrapper for crypt_blowfish that provides Bcrypt hashing.
The C module and most of the code in the Bcrypt class is taken from cryptacular with Daniel Holth's permission.
Installation
Download Himitsu from Github and run the following command. Keep in mind that Himitsu has only been tested with Python 2.7 and 3.2.
python setup.py install
Or from PyPi:
pip install himitsu
And you're done.
Usage
Example:
import himitsu
b = himitsu.Bcrypt()
Create a hash:
h = b.encode('password')
Make sure a hash is valid:
print b.valid(h)
Check a hash (validity of hash is also checked):
print b.check(h, 'password')
API
All of the following functions and constants are from the himitsu module.
himitsu.Bcrypt
__init__
rounds: The default amount of rounds.
encode
Encode a piece of text (e.g. a password).
text: The text that's going to be hashed/encoded.rounds: The amount of rounds. Optional.
check
Compare an piece of text with a hash.
encoded: A hash previously encoded withencode.text: The text that need to be checked.
valid
Check if a hash is valid.
encoded: A hash previously encoded withencode.
Changelog
0.1.0 (2011-09-08)
- Initial release.
License
Copyright (C) 2011 by Frank Smit frank@61924.nl
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.