Text Hash
Calculates a cryptographic hash value from text input using various hash algorithms. Hash functions create fixed-size fingerprints of data, useful for integrity verification, password storage, and data deduplication.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Text - The text string to hash. Can be any text content.
Options
- Hash Function - The cryptographic hash algorithm to use:
- md5 - MD5 (128-bit) - Fast but not secure for cryptographic use
- sha1 - SHA-1 (160-bit) - Deprecated for security, use SHA-256+
- sha256 - SHA-256 (256-bit) - Recommended for most use cases
- sha512 - SHA-512 (512-bit) - Higher security, larger output
- blake256 - BLAKE-256 (256-bit) - Fast and secure alternative
- blake512 - BLAKE-512 (512-bit) - Fast and secure alternative
- whirlpool - Whirlpool (512-bit) - High security hash function
Output
- hash - The computed hash value in hexadecimal format.
How It Works
The Text Hash node applies one-way cryptographic hash functions to text:
- Receives the input text and selected hash function
- Converts the text to bytes
- Applies the selected hash algorithm:
- MD5: 128-bit digest
- SHA-1: 160-bit digest
- SHA-256: 256-bit digest
- SHA-512: 512-bit digest
- BLAKE-256/512: 256/512-bit digest
- Whirlpool: 512-bit digest
- Encodes the hash output as hexadecimal string
- Returns the hash value
Hash functions are one-way: you cannot reverse a hash to get the original text.
Example Usage
Verify Data Integrity
// Calculate hash before and after transmission
const originalText = "Important document content...";
// Use Text Hash node with SHA-256
// Output: hash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
// After transmission, hash again and compare
// If hashes match, data is intact
Password Hashing (Basic)
// Hash password before storage (use bcrypt/argon2 for production)
const password = "MySecurePassword123!";
// Use Text Hash node with SHA-256
const passwordHash = "{{msg.hash}}";
// Store passwordHash in database, not the plain password
Detect Data Changes
// Monitor configuration for changes
const currentConfig = JSON.stringify(configObject);
// Use Text Hash node
const currentHash = "{{msg.hash}}";
// Compare with stored hash
if (currentHash !== storedHash) {
console.log("Configuration has been modified");
}
Content Deduplication
// Check if content already exists
const documentContent = "Lorem ipsum dolor sit amet...";
// Use Text Hash node with SHA-256
const contentHash = "{{msg.hash}}";
// Query database for existing hash
// If found, document is duplicate
Create Unique Identifiers
// Generate deterministic ID from data
const userData = JSON.stringify({
email: "user@example.com",
timestamp: "2024-01-15T10:30:00Z"
});
// Use Text Hash node with SHA-256
const uniqueId = "{{msg.hash}}";
// Use hash as unique identifier
Verify API Responses
// Verify API response hasn't been tampered with
const responseData = JSON.stringify(apiResponse);
// Use Text Hash node
const dataHash = "{{msg.hash}}";
// Compare with hash from API header
if (dataHash !== apiResponse.headers['X-Content-Hash']) {
console.log("Response may have been modified");
}
Requirements
- Valid text input (can be empty string)
- No special characters restrictions - all UTF-8 text supported
Error Handling
The node handles all text input gracefully. Errors are rare but may occur:
- Memory issues - Extremely large text input
- Encoding errors - Invalid UTF-8 sequences
Hash Algorithm Comparison
Security Level
- Cryptographically Broken: MD5, SHA-1
- Secure: SHA-256, SHA-512, BLAKE-256, BLAKE-512, Whirlpool
Speed (Fastest to Slowest)
- MD5
- SHA-1
- BLAKE-256
- SHA-256
- BLAKE-512
- SHA-512
- Whirlpool
Output Size
- MD5: 32 hex characters (128 bits)
- SHA-1: 40 hex characters (160 bits)
- SHA-256, BLAKE-256: 64 hex characters (256 bits)
- SHA-512, BLAKE-512, Whirlpool: 128 hex characters (512 bits)
Recommendations
- General Use: SHA-256 (good balance of security and performance)
- High Security: SHA-512 or BLAKE-512
- Performance Critical: BLAKE-256 (faster than SHA-256, equally secure)
- Legacy Compatibility: MD5 or SHA-1 (only when required by legacy systems)
- Avoid for Security: MD5, SHA-1 (both have known vulnerabilities)
Common Use Cases
- Data Integrity - Verify data hasn't been modified during storage or transmission
- Password Storage - Hash passwords before database storage (consider bcrypt/argon2 for production)
- Deduplication - Identify duplicate content by comparing hashes
- Digital Fingerprints - Create unique identifiers for data
- Change Detection - Monitor for configuration or file changes
- Cache Keys - Generate cache keys from request parameters
- Checksums - Verify download integrity
- Blockchain - Create hash chains for audit trails
Security Best Practices
- Use SHA-256 or higher - Avoid MD5 and SHA-1 for security-critical applications
- Don't use for passwords - Use bcrypt, argon2, or PBKDF2 for password hashing
- Add salt for passwords - If you must use hash functions, add unique salt per user
- Hash sensitive data - Consider hashing before logging or displaying
- Verify integrity - Use hashes to detect tampering or corruption
- Use HMAC for authentication - For message authentication, use HMAC Signature node
- Don't rely on hash uniqueness - Collisions are theoretically possible
Tips for Effective Use
- Choose hash algorithm based on your security requirements
- Use consistent hash algorithms across your application
- Store hashes alongside data for integrity verification
- Compare hashes in constant time to prevent timing attacks
- Consider using HMAC for authenticated hashing
- Hash JSON by stringifying with sorted keys for consistency
- Use base64 encoding if hexadecimal is too long
- Test hash generation with known inputs to verify correctness
Hash Consistency
For consistent hashes across different systems:
// Consistent JSON hashing
const data = {name: "John", age: 30, city: "NYC"};
// Sort keys before stringifying
const sortedData = JSON.stringify(data, Object.keys(data).sort());
// Use Text Hash node
// Same data will always produce same hash
Performance Considerations
- Text length: Hashing time increases linearly with text size
- Algorithm choice: BLAKE algorithms are faster than SHA for large inputs
- Frequency: Hashing is CPU-bound, consider caching for frequently accessed data
- Parallel processing: Can hash multiple texts in parallel
Troubleshooting
Different Hashes for Same Data
- Whitespace differences - Trim or normalize whitespace
- Encoding issues - Ensure consistent UTF-8 encoding
- Line endings - Normalize line endings (CRLF vs LF)
- JSON key order - Sort JSON keys before stringifying
Hash Collisions
- Use stronger algorithms - Switch from MD5/SHA-1 to SHA-256+
- Add context - Include timestamps or random values if uniqueness critical
Related Nodes
- File Hash - Calculate hash of file contents
- HMAC Signature - Create authenticated hashes with secret key
- Encrypt Text - Encrypt text instead of hashing
- Sign - Create RSA digital signatures