BLAKE: an excellent hash algorithm

BLAKE is a NIST SHA3 competition finalist designed and submitted by Jean-Philippe Aumasson, Luca Henzen, Willi Meier, and Raphael C.-W. Phan. At the core of BLAKE is a ChaCha-like mixer, very similar to that found in the stream cipher, ChaCha, a tweak of Salsa20. Besides being a very good mixer, ChaCha is fast. More at:
            http://www.131002.net/blake/
            http://csrc.nist.gov/groups/ST/hash/sha-3/index.html
            http://en.wikipedia.org/wiki/BLAKE_(hash_function)

This page introduces blake.py, a pure Python implementation of BLAKE-224, -256, -384, -512, and blake_wrapper.py, a ctypes wrapper for a shared library using the official C reference APIs. Also, you might find use for the test program blake_test.py. All of these should run nicely under Python 2.6 and later. This includes Python3 and PyPy.

These implementations assume all data is in increments of whole bytes. (The formal definition of BLAKE allows for hashing in increments of individual bits.) Note too that this implementation does include the round-3 tweaks where the number of rounds was increased from 10/14 to 14/16.

Comparative blake.py run times of CPython on a 64-bit processor are more than twice as fast as on a 32-bit processor. ...and several years ago pypy was about 3 times faster than CPython. A raw C implementation might be faster yet but pypy performance has improved dramatically over the last few years so you may want to run your own benchmarks.

License:
Copyright (c) 2009-2018 Larry Bugbee, Kent, WA, USA

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

      (the ISC license, a minor tweak of the BSD license)

blake.py   (version 5, 2-Apr-2014)
blake_wrapper.py
blake_test.py

Enjoy,

Larry Bugbee
bugbee@seanet.com
Mar 2011
rev Jul 2011, Apr 2012, Apr 2014, Mar 2018