lib.hashing.*

File hashing services

Provides

  • genkey() - Generates hash key

  • sign() - Returns a signature for a given file

  • verify() - Verifies file against signature

lib.hashing.genkey(nbytes=64)[source]

Returns a random byte sting that may be used as signature key

Parameters

nbytes (int) – Length of key

Return type

bytes

Returns

Random byte string of length nbytes

lib.hashing.sign(data, key)[source]

Returns signature for file using blake2b

Note: 64 bytes is the maximum that is supported in Python’s BLAKE2b

Parameters
  • data (bytes) – Data to be signed

  • key (bytes) – Signature key, len(key) <= 64

Return type

bytes

Returns

File signature hexdigest, encoded in utf-8

lib.hashing.verify(data, signature, key)[source]

Verifies a signature

Parameters
  • data (bytes) – Data to be verified

  • signature (bytes) – Signature for verification

  • key (bytes) – Signature key, len(key) <= 64

Return type

bool

Returns

True if verification was successful else False