This module provides a simple hash calculator that supports SHA-256 and SHA3-256 algorithms.
-
Run the
hash_calculator.pymodule directly to calculate the hash for a given string.python hash_calculator.py
-
Use the
calculate_hashfunction in your Python code.from py_scripts.hash_calculator import calculate_hash input_string = "Hello World" algorithm_flag = 1 # 1 for SHA-256, 2 for SHA3-256 result = calculate_hash(input_string, algorithm_flag) print(f"Hash result: {result}")
This script can serve as a simple mock for using the calculate_hash function directly in C code. You can integrate the hash calculation functionality into your C program by calling the Python function using appropriate bindings or interfacing techniques.
To run the tests, execute the following command from the project root:
python -m unittest py_scripts.test.hash_calculator_test