conda_recipe_manager.utils.cryptography.hashing

Description:

Provides hashing utilities.

Functions

hash_file(file, hash_algo)

Hashes a file from disk with the given algorithm and returns the hash as a hexadecimal string.

hash_str(s, hash_algo[, encoding])

Hashes an in-memory string with the given algorithm and returns the hash as a hexadecimal string.

conda_recipe_manager.utils.cryptography.hashing.hash_file(file: str | Path, hash_algo: str | Callable[[], hashlib._Hash]) str[source]

Hashes a file from disk with the given algorithm and returns the hash as a hexadecimal string.

Parameters:
  • file -- Target file.

  • hash_algo -- Hash algorithm function defined provided by hashlib. This can be a string name recognized by hashlib or a reference to a hash constructor.

Returns:

The hash of the file, as a hexadecimal string.

conda_recipe_manager.utils.cryptography.hashing.hash_str(s: str, hash_algo: Callable[[bytes], hashlib._Hash], encoding: str = 'utf-8') str[source]

Hashes an in-memory string with the given algorithm and returns the hash as a hexadecimal string.

Parameters:
  • s -- Target string.

  • hash_algo -- Hash algorithm function defined provided by hashlib. For example pass-in hashlib.sha256 to to perform a SHA-256 hash.

  • encoding -- (Optional) String encoding to use when interpreting the string as bytes. Defaults to utf-8.

Returns:

The hash of the string contents, as a hexadecimal string.