CreateHash

Creating a hash of a given input, support sha1, sha256, sha512, md5 and blake. Wrapper for https://docs.python.org/3/library/hashlib.html.

python · Common Scripts

Details

IDCreateHash
Languagepython
From Version6.0.0
Docker Imagedemisto/python3:3.12.13.10404775
Tagstransformer Utilities hash

README

Creating a hash of a given input, support sha1, sha256, sha512, md5 and blake. Wrapper for https://docs.python.org/3/library/hashlib.html

Script Data


Name Description
Script Type python3
Tags transformer, Utilities, hash

Inputs


Argument Name Description
text Text or string for which a hash should be created.
type Hash method to be used.

Outputs


Path Description Type
CreateHash   string
import pytest


@pytest.mark.parametrize("hash_method", ["sha512", "sha256", "sha1", "md5", ""])
def test_create_hash(hash_method):
    """
    Given:
        - A string
    When:
        - Running the script
    Then:
        - Ensure the expected hash is returned
    """
    from CreateHash import create_hash

    context = create_hash("test", hash_method)

    assert isinstance(context, dict)
    assert isinstance(context.get("CreateHash"), str)