This project implements a custom hash function and compares it with the popular cryptographic hash function, SHA-256. The app is built using Streamlit and allows users to input a string, view its hash generated by both the custom algorithm and SHA-256, and compare the results. The project demonstrates how slight changes in input result in significant differences in the hash output.
The custom hash function uses ASCII manipulation, modular arithmetic, and compression to produce a fixed-length hash.
- Custom Hash Function: Generates a unique hash based on the input string using an algorithm involving ASCII values, modular arithmetic, and compression.
- SHA-256 Comparison: Shows how the custom hash compares to the widely-used SHA-256 hash function.
- Interactive Interface: Built with Streamlit for easy use and deployment. Allows users to input strings and see hash outputs in real-time.
- Input Validation: Prevents the user from submitting empty strings and provides helpful feedback.
- GitHub Repository: Contains the source code and the app for comparison.
You can view and interact with the live demo on Custom-Hash.
To run this project locally, ensure you have the following installed:
- Python (>= 3.7)
- pip (Python's package manager)
-
Clone the repository:
git clone https://github.com/Adhhiiiiiiii/custom-hash.git cd custom-hash -
Install required dependencies:
pip install -r requirements.txt
-
Run the app: Start the Streamlit app by running:
streamlit run app.py
-
Visit the app: Open your browser and go to
http://localhost:8501to view the app.
- Enter a string in the provided text box.
- Click "Generate Hash" to see the custom hash and the SHA-256 hash for the input string.
- Compare the generated hashes to see how the custom hash function differs from SHA-256.
- The app also provides an example string ("hello") when the app loads.
For example:
-
Input:
hello- Custom Hash:
a3c7e2f5d93cfb4a560e...(A 32-character hash generated by the custom algorithm) - SHA-256 Hash:
2cf24dba5fb0a30e26e83b2ac5b9e29e1b169e6b846b7f7d167a16f7d5bce8e3(Standard SHA-256 output)
- Custom Hash:
- Small changes in the input will result in large differences in the hash output, demonstrating the avalanche effect of cryptographic hash functions.
- This app is for educational purposes to demonstrate how hashing algorithms work.
- Python 3.x
- Streamlit (
pip install streamlit) - hashlib (comes with Python standard library)
streamlit==1.11.1- Streamlit: For providing an easy-to-use framework to build web applications.
- hashlib: For the cryptographic hashing functions in Python.
This project is open-source and designed for educational purposes, providing accessible insights into hash functions for all users.
