Encoding & Hashing
Relevant source files
The following files were used as context for generating this wiki page:
The Encoding & Hashing modules within DevUtils provide a robust suite of tools for data transformation, cryptographic hashing, and format conversion. Designed for developers, these modules support a wide array of standards including various Base encoding schemes (Base16, 32, 64, 85), common cryptographic hashes (MD5, SHA family), and password-specific algorithms like BCrypt and Argon2. Sources: README.md:9-10, messages/en.json:52-111, messages/en.json:448-500
These tools are implemented as client-side React components that leverage high-performance libraries such as hash-wasm and crypto-js to perform operations locally, ensuring data privacy. They include specialized handling for both raw text and large files through streaming interfaces. Sources: package.json:44-50, components/tools/hash-generator.tsx:1-40, components/tools/base64-tool.tsx:1-35
Data Encoding Systems
The encoding system, primarily housed in the Base64Tool component, facilitates bidirectional transformation between plaintext/binary and various text-based encoding formats. It supports both immediate text processing and file-based workflows. Sources: components/tools/base64-tool.tsx:29-33
Supported Encoding Formats
The system implements five primary encoding standards:
- Base16 (Hex): Standard hexadecimal representation.
- Base32: 5-bit encoding using an alphanumeric alphabet.
- Base64: Standard 6-bit encoding.
- Base64URL: URL and filename safe variant of Base64.
- ASCII85: High-efficiency encoding (85 characters) often used in PostScript and PDF.
Sources: components/tools/base64-tool.tsx:27, messages/en.json:61-67
File Processing Architecture
For file encoding, the application uses a streaming approach to handle large assets without exhausting browser memory. It calculates chunk alignments based on the specific requirements of the selected encoding format to ensure data integrity across chunk boundaries. Sources: components/tools/base64-tool.tsx:443-465
The diagram shows how the system ensures data integrity by aligning file chunks to the specific byte-multiples required by each encoding algorithm. Sources: components/tools/base64-tool.tsx:446-460
Cryptographic Hashing
The Hashing system provides a unified interface for generating message digests and secure password hashes. It utilizes the hash-wasm library for performance-critical operations and bcryptjs for specialized password hashing. Sources: components/tools/hash-generator.tsx:35-55, package.json:44-50
Hash Algorithms and Configurations
The system categorizes hashes into standard digests and configurable KDFs (Key Derivation Functions):
| Category | Algorithms | Key Parameters |
|---|---|---|
| Standard | MD5, SHA-1, SHA-2 (224, 256, 384, 512) | N/A |
| SHA-3 | SHA3-224, SHA3-256, SHA3-384, SHA3-512 | N/A |
| Password | BCrypt, Argon2id | Rounds, Iterations, Memory, Salt |
| Sources: components/tools/hash-generator.tsx:57-70, messages/en.json:456-480 |
Argon2 Implementation Logic
Argon2id is implemented with highly granular configuration options, allowing users to tune the algorithm's resistance to GPU/ASIC cracking. Sources: components/tools/hash-generator.tsx:210-224
The sequence illustrates the validation and execution flow for the Argon2id algorithm. Sources: components/tools/hash-generator.tsx:97-111, components/tools/hash-generator.tsx:213-224
Data Format Conversion
Beyond raw encoding, the system includes a DataConverter module for structural transformations between common data serialization formats. Sources: components/tools/data-converter.tsx:1-25
Transformation Capabilities
The system converts between the following formats:
- JSON: Supports an "Auto-fix" feature to repair malformed JSON (missing quotes, trailing commas, unbalanced braces).
- CSV/TSV: Handles flattening of nested objects into a tabular format.
- XML: Converts objects to tagged structures with support for attributes (via
@prefix). - YAML: Generates human-readable serialization with automatic quoting for special characters.
Sources: components/tools/data-converter.tsx:35-70, components/tools/data-converter.tsx:205-255, components/tools/data-converter.tsx:313-356
JSON Repair Logic
The "Auto-fix" functionality uses a series of regular expression passes to transform common "loose" JSON into strict, valid JSON. Sources: components/tools/data-converter.tsx:37-64
This diagram represents the multi-stage regex pipeline used to sanitize and repair user-provided JSON input. Sources: components/tools/data-converter.tsx:40-60
Implementation Details
File Integration with Tauri
Both encoding and hashing tools integrate with the Tauri runtime to support native file system operations and drag-and-drop functionality. Sources: components/tools/hash-generator.tsx:370-395, components/tools/base64-tool.tsx:492-515
- Drag-and-Drop: Uses
getCurrentWebview().onDragDropEventto capture file paths. - FS Plugin: Utilizes
@tauri-apps/plugin-fsto read file contents intoUint8Arrayfor processing.
Sources: components/tools/hash-generator.tsx:375-385, package.json:42
Performance Optimization
- Memory Management: Large files are processed via
file.slice()to create Blobs/Uint8Arrays in chunks rather than loading the entire file into RAM. Sources: components/tools/hash-generator.tsx:165-175, components/tools/base64-tool.tsx:445-455 - Concurrency: Argon2 parallelism is configurable, allowing the tool to utilize multiple threads if the underlying WASM implementation supports it. Sources: components/tools/hash-generator.tsx:106-111
Encoding and Hashing tools in DevUtils provide a comprehensive, client-side solution for data manipulation, emphasizing both ease of use for simple text and performance for large-scale file operations. Sources: README.md:1-5, components/tools/data-converter.tsx:400-450