cyclonedx.contrib.hash.factories

Hash related factories

Classes

HashTypeFactory

Module Contents

class cyclonedx.contrib.hash.factories.HashTypeFactory
from_hashlib_alg(hashlib_alg: str, content: str) cyclonedx.model.HashType

Attempts to convert a hashlib-algorithm to our internal model classes.

Args:
hashlib_alg:

Hash algorith - like it is used by hashlib. Example: sha256.

content:

Hash value.

Raises:

UnknownHashTypeException if the algorithm of hash cannot be determined.

Returns:

An instance of HashType.

from_composite_str(composite_hash: str) cyclonedx.model.HashType

Attempts to convert a string which includes both the Hash Algorithm and Hash Value and represent using our internal model classes.

Args:
composite_hash:

Composite Hash string of the format HASH_ALGORITHM:HASH_VALUE. Example: sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b.

Valid case insensitive prefixes are: md5, sha1, sha256, sha384, sha512, blake2b256, blake2b384, blake2b512, blake2256, blake2384, blake2512, sha3-256, sha3-384, sha3-512, blake3.

Raises:

UnknownHashTypeException if the type of hash cannot be determined.

Returns:

An instance of HashType.