| 1 |
BLAKE2s |
| 2 |
======= |
| 3 |
|
| 4 |
`BLAKE2s`_ is an optimized variant of BLAKE, one of the SHA-3 candidates that |
| 5 |
made it to the final round of the NIST hash competition. |
| 6 |
It is specified in `RFC7693 <https://tools.ietf.org/html/rfc7693>`_. |
| 7 |
|
| 8 |
The algorithm uses 32 bit words, and it therefore works best on |
| 9 |
32-bit platforms. The digest size ranges from 8 to 256 bits:: |
| 10 |
|
| 11 |
>>> from Crypto.Hash import BLAKE2s |
| 12 |
>>> |
| 13 |
>>> h_obj = BLAKE2s.new(digest_bits=256) |
| 14 |
>>> h_obj.update(b'Some data') |
| 15 |
>>> print h_obj.hexdigest() |
| 16 |
|
| 17 |
Optionally, BLAKE2s can work as a cryptographic MAC when initialized |
| 18 |
with a secret key:: |
| 19 |
|
| 20 |
>>> from Crypto.Hash import BLAKE2s |
| 21 |
>>> |
| 22 |
>>> mac = BLAKE2s.new(digest_bits=128, key=b'secret') |
| 23 |
>>> mac.update(b'Some data') |
| 24 |
>>> print mac.hexdigest() |
| 25 |
|
| 26 |
.. _BLAKE2b: https://blake2.net/ |
| 27 |
|
| 28 |
.. automodule:: Crypto.Hash.BLAKE2s |
| 29 |
:members: |