maci.createhash

create hash of data

Creates a hash of the provided data, and returns a string of the hash.

maci.createhash -> str

Basic Example of hashing data using the default positional parameter

hashed_data = maci.createhash(data)

In this example, we simply input the data desired to hash using the createhash function and pass the data as an argument to the function, and assign the returned hashed data to a variable.

This function accepts simple or specific data type structures. Strings or bytes for example are some of the simple ones, but see data_to_hash parameter below to see other options.

parameters & arguments

Describes all parameter functionality and accepted data types

data_to_hash: str | bytes | int | list[int] | tuple[int] | set[int] | range | bool

First and only required positional argument. Accepts strings, bytes, integers, list of integers, tuple of integers, set of integers, range objects, and booleans

Use this parameter to input the data to get hashed.

Note: the current selection of data allowed to get hashed is related to the built-in bytes function.

hash_algorithm: str

Optional parameter. Accepts strings. Default = 'sha256'

Use this parameter to set the hash algorithm used for the hash. Default is sha256, which is a current common industry standard.

All options available: 'sha256', 'sha512', 'sha384', 'sha1', 'md5'

encoding: str

Optional parameter. Accepts strings. Default = 'utf-8'

Use this parameter to set the desired codec of the data if needed. The default uses a common industry standard, so you don't have to use this, but you can if the data needs to be written with a specific codec.

Last updated