A Next.js web application providing cryptographic utilities powered by Rust WebAssembly (WASM).
- Hash strings with salt using SHA-256
- Single hash mode with textarea support (supports newlines)
- Multiple hash mode for batch processing
- Real-time hashing with instant results
- Encrypt and decrypt text using AES-256-GCM
- Automatic nonce generation or custom nonce support
- Key generation utility
- Base64-encoded output
- Encrypt and decrypt files using AES-256-GCM
- Automatic nonce generation or custom nonce support
- Custom output filename support
- Manual download with download button
- Modern, responsive UI with dark mode support
- Feature tabs for easy navigation
- Local storage persistence for user preferences
- Smooth transitions and loading states
.
├── frontend/ # Next.js frontend application
│ ├── app/
│ │ ├── components/ # React components
│ │ │ ├── HashForm.tsx # Hash feature component
│ │ │ ├── EncryptDecryptForm.tsx # Text encrypt/decrypt component
│ │ │ ├── EncryptDecryptFileForm.tsx # File encrypt/decrypt component
│ │ │ └── ... # Other UI components
│ │ ├── contexts/
│ │ │ └── WasmContext.tsx # WASM module context provider
│ │ ├── utils/
│ │ │ └── wasm-loader.ts # WASM module loader
│ │ ├── page.tsx # Main page with feature tabs
│ │ └── layout.tsx # Root layout
│ ├── wasm/
│ │ └── pkg/ # Built WASM package (generated)
│ └── package.json
└── wasm/ # Rust WASM module source
├── src/
│ └── lib.rs # Rust source with hash, encrypt, decrypt functions
├── Cargo.toml # Rust dependencies
└── build.sh # Build script
- Node.js (v18 or higher)
- Bun (or npm/yarn) for package management
- Rust (install from https://rustup.rs/)
- wasm-pack (will be installed automatically, or install manually)
-
Install frontend dependencies:
cd frontend bun install -
Build the WASM module:
cd wasm chmod +x build.sh ./build.shThe WASM module will be built directly into
frontend/wasm/pkg/.Or use the npm script from the frontend directory:
cd frontend npm run build:wasm
-
Start the development server:
cd frontend bun run dev -
Open http://localhost:3000 in your browser.
-
Build the WASM module:
npm run build:wasm
-
Build the Next.js application:
cd frontend bun run build -
Start the production server:
bun run start
The project is configured for Vercel deployment with vercel.json.
Prerequisites:
- Vercel account
- Rust toolchain (Vercel will install it automatically if needed)
Deployment Steps:
-
Connect your repository to Vercel:
- Go to vercel.com
- Import your Git repository
- Vercel will auto-detect the Next.js framework
-
Configure build settings (if needed):
- Root Directory:
frontend - Build Command:
npm run build:wasm && npm run build(auto-detected) - Output Directory:
.next(auto-detected)
- Root Directory:
-
Deploy:
- Vercel will automatically build and deploy on every push to your main branch
- The build process will:
- Install dependencies
- Build the WASM module (requires Rust)
- Build the Next.js application
- Deploy to Vercel's edge network
Note: The first build may take longer as Vercel installs Rust and wasm-pack. Subsequent builds will be faster due to caching.
-
Rust WASM Module (
wasm/src/lib.rs):hash_string: Hashes strings with salt using SHA-256encrypt/decrypt: Encrypts/decrypts text using AES-256-GCMencrypt_file/decrypt_file: Encrypts/decrypts files using AES-256-GCMgenerate_key: Generates random 32-byte encryption keys- All functions are compiled to WebAssembly using
wasm-pack
-
Next.js Frontend:
- Loads the WASM module once at the page level for optimal performance
- Provides three feature tabs:
- Hash: Single or multiple string hashing with salt
- Encrypt/Decrypt: Text encryption and decryption
- Encrypt/Decrypt File: File encryption and decryption
- Uses React Context for global WASM module access
- Persists user preferences (active feature, mode) in localStorage
-
State Management:
- Each feature maintains its own state
- Inputs and results are preserved when switching between features
- File uploads persist when switching between encrypt/decrypt modes
- WASM module not found: Make sure you've built the WASM module and it's accessible at
frontend/wasm/pkg/. The build script outputs directly to this location. - Build errors: Ensure Rust and wasm-pack are properly installed
- Import errors: Check that the WASM package path is correct in
frontend/app/utils/wasm-loader.ts(should be../../wasm/pkg/mfoa_hash_wasm)