Skip to content

Adhhiiiiiiii/custom-hash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom Hash

Description

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.

Features

  • 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.

Live Demo

You can view and interact with the live demo on Custom-Hash.

App Screenshot

Installation

Prerequisites

To run this project locally, ensure you have the following installed:

  • Python (>= 3.7)
  • pip (Python's package manager)

Step-by-Step Guide

  1. Clone the repository:

    git clone https://github.com/Adhhiiiiiiii/custom-hash.git
    cd custom-hash
  2. Install required dependencies:

    pip install -r requirements.txt
  3. Run the app: Start the Streamlit app by running:

    streamlit run app.py
  4. Visit the app: Open your browser and go to http://localhost:8501 to view the app.

Usage

  1. Enter a string in the provided text box.
  2. Click "Generate Hash" to see the custom hash and the SHA-256 hash for the input string.
  3. Compare the generated hashes to see how the custom hash function differs from SHA-256.
  4. The app also provides an example string ("hello") when the app loads.

Example Input and Output

For example:

  • Input: hello

    • Custom Hash: a3c7e2f5d93cfb4a560e... (A 32-character hash generated by the custom algorithm)
    • SHA-256 Hash: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b169e6b846b7f7d167a16f7d5bce8e3 (Standard SHA-256 output)

Important Notes

  • 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.

Requirements

  • Python 3.x
  • Streamlit (pip install streamlit)
  • hashlib (comes with Python standard library)

requirements.txt

streamlit==1.11.1

Acknowledgments

  • Streamlit: For providing an easy-to-use framework to build web applications.
  • hashlib: For the cryptographic hashing functions in Python.

License

This project is open-source and designed for educational purposes, providing accessible insights into hash functions for all users.

About

This project uses Streamlit to compare a custom hash function with SHA-256. Users can input a string and observe how minor changes affect the hash results.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages