/usr/lib/python2.7/dist-packages/libnacl/blake.py is in python-libnacl 1.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 | '''
Mimic very closely the python hashlib classes for blake2b
NOTE:
This class does not yet implement streaming the msg into the
hash function via the update method
'''
# Import python libs
import binascii
# Import libnacl libs
import libnacl
class Blake2b(object):
'''
Manage a Blake2b hash
'''
def __init__(self, msg, key=None):
self.msg = msg
self.key = key
self.raw_digest = libnacl.crypto_generichash(msg, key)
self.digest_size = len(self.raw_digest)
def digest(self):
'''
Return the digest of the string
'''
return self.raw_digest
def hexdigest(self):
'''
Return the hex digest of the string
'''
return binascii.hexlify(self.raw_digest)
def blake2b(msg, key=None):
'''
Create and return a Blake2b object to mimic the behavior of the python
hashlib functions
'''
return Blake2b(msg, key)
|