File: raw_generichash.rst

package info (click to toggle)
python-libnacl 2.1.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 488 kB
  • sloc: python: 2,634; makefile: 149; sh: 3
file content (31 lines) | stat: -rw-r--r-- 806 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
====================================
Raw Generic Hash (Blake2b) Functions
====================================

The nacl library comes with blake hashing libraries.

More information on Blake can be found here:
https://blake2.net

The blake2b hashing algorithm is a keyed hashing algorithm, which allows
for a key to be associated with a hash. Blake can be executed with or without
a key.

With a key (they key can should be between 16 and 64 bytes):

.. code-block:: python

    import libnacl

    msg = 'Is there someone else up there we could talk to?'
    key = libnacl.randombytes(32)
    h_msg = libnacl.crypto_generichash(msg, key)

Without a key:

.. code-block:: python

    import libnacl

    msg = 'Is there someone else up there we could talk to?'
    h_msg = libnacl.crypto_generichash(msg)