Skip to content

achintya-7/hash-forge

Repository files navigation

Hash Forge

A fast, privacy-focused file hashing tool built with Go WebAssembly and React. Calculate XXH3 hashes of your files directly in your browser - no files ever leave your device.

🌐 Live Demo

Hash Forge Go React WebAssembly

✨ Features

  • πŸ”’ 100% Private: All processing happens locally in your browser - files never leave your device
  • ⚑ Lightning Fast: Powered by Go WebAssembly for optimal performance
  • πŸ“ Multiple Files: Process multiple files at once with sequential processing
  • 🎨 Modern UI: Clean, responsive interface built with React and Tailwind CSS
  • 🌐 Cross-Platform: Works on any device with a modern web browser
  • πŸ“¦ Easy Deployment: Docker support for easy hosting

πŸš€ Quick Start

Prerequisites

  • Go 1.24 or later
  • Node.js 18 or later
  • Docker (optional, for containerized deployment)

Local Development

  1. Clone the repository

    git clone https://github.com/achintya-7/hash-forge.git
    cd hash-forge
  2. Install Node.js dependencies

    npm install
  3. Build the WebAssembly module

    npm run build:wasm
  4. Start the development server

    npm run dev
  5. Open your browser Navigate to http://localhost:5173 to use the application.

Production Build

  1. Build the WebAssembly module

    npm run build:wasm
  2. Build the React application

    npm run build
  3. Serve the built files

    npm run preview

🐳 Docker Deployment

Using Docker (Recommended for Self-Hosting)

  1. Build and run with Docker
    ./docker-build.sh

πŸš€ GitHub Pages Deployment

Automatic Deployment (Recommended)

This project is configured for automatic deployment to GitHub Pages using GitHub Actions.

  1. Fork or clone this repository to your GitHub account

  2. Enable GitHub Pages in your repository:

    • Go to your repository settings
    • Navigate to "Pages" section
    • Under "Source", select "GitHub Actions"
  3. Push to the master branch:

    git add .
    git commit -m "Deploy to GitHub Pages"
    git push origin master
  4. Access your deployed app: Your app will be available at: https://yourusername.github.io/hash-forge/

Manual Deployment

If you prefer to deploy manually:

  1. Build the project locally:

    npm run deploy
  2. Deploy using GitHub CLI (if installed):

    gh workflow run deploy.yml

Manual Docker Commands

  1. Build the Docker image

    docker build -t hash-forge .
  2. Run the container

    docker run -p 3000:80 --name hash-forge-container hash-forge
  3. Access the application Open http://localhost:3000 in your browser.

Docker Management

# Stop the container
docker stop hash-forge-container

# Remove the container
docker rm hash-forge-container

# View logs
docker logs hash-forge-container

πŸ—οΈ Project Structure

hash-forge/
β”œβ”€β”€ go/                     # Go WebAssembly source
β”‚   β”œβ”€β”€ main.go            # Main WASM entry point
β”‚   β”œβ”€β”€ go.mod             # Go module definition
β”‚   └── go.sum             # Go module checksums
β”œβ”€β”€ src/                   # React source code
β”‚   β”œβ”€β”€ App.tsx            # Main React component
β”‚   β”œβ”€β”€ components/        # UI components
β”‚   └── lib/               # Utility functions
β”œβ”€β”€ public/                # Static files
β”‚   β”œβ”€β”€ main.wasm          # Compiled WebAssembly binary
β”‚   └── wasm_exec.js       # Go WebAssembly runtime
β”œβ”€β”€ Dockerfile             # Multi-stage Docker build
β”œβ”€β”€ docker-build.sh        # Docker build script
└── package.json           # Node.js dependencies

πŸ› οΈ Available Scripts

Development

  • npm run dev - Start development server
  • npm run build:wasm - Build Go WebAssembly module
  • npm run build - Build production React app
  • npm run preview - Preview production build

Docker

  • ./docker-build.sh - Build and run Docker container
  • npm run docker-build-and-run - Same as above

Code Quality

  • npm run lint - Run ESLint

πŸ”§ Technology Stack

Backend (WebAssembly)

  • Go 1.24: Core language for WebAssembly compilation
  • XXH3: Fast, high-quality hash algorithm via zeebo/xxh3
  • syscall/js: Go's WebAssembly browser interface

Frontend

  • React 19.1: Modern UI framework with hooks
  • TypeScript: Type-safe JavaScript development
  • Vite: Fast build tool and development server
  • Tailwind CSS: Utility-first CSS framework
  • shadcn/ui: Beautiful, accessible UI components

Development & Deployment

  • Docker: Multi-stage containerized deployment
  • nginx: Production web server
  • ESLint: Code linting and formatting

πŸ“– How It Works

  1. File Selection: Choose one or more files using the file input
  2. WebAssembly Loading: Go WASM module loads in the browser
  3. Hash Calculation: Files are processed locally using the XXH3 algorithm
  4. Results Display: Hash results are shown with copy functionality

WebAssembly Integration

The Go code is compiled to WebAssembly and exposes a hashFile function:

func hashFile(this js.Value, args []js.Value) interface{} {
    // File processing logic
    fileData := args[0]
    buffer := make([]byte, fileData.Get("length").Int())
    js.CopyBytesToGo(buffer, fileData)

    // Calculate hash
    finalHash := xxh3.Hash(buffer)
    return fmt.Sprintf("%d", finalHash)
}

The React frontend calls this function:

const hash = window.hashFile(uint8Array);

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

If you encounter any issues or have questions:

  1. Check the Issues page
  2. Create a new issue with detailed information
  3. Contact the maintainer: @achintya-7


Made with ❀️ by Achintya

About

A fast, privacy-focused file hashing tool built with Go WebAssembly and React

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published