- JSON Formatter/Viewer
Format, minify, visualize and validate JSON.
- JSON Diff
Compare two JSON objects.
- JSON Schema Validator
Validate JSON schema online
- Base64 Encode/Decode
Encode and decode Base64.
- URL Encode/Decode
Encode and decode URL.
- UUID Generator v4 / v1
Generate UUIDs in v4 and other versions.
- Text Hash
Generate cryptographic hashes from your text input using a wide variety of algorithms.
- File Hash
Generate cryptographic hashes from your file using a wide variety of algorithms.
- JWT Decoder & Validator
Decode and validate JSON Web Tokens.
- CSV Viewer
View CSV data in a table.
- CSV to JSON Converter
Convert CSV to JSON.
- JSON to CSV Converter
Convert JSON to CSV.
Golang MD5 Hash
Learn how to generate an MD5 hash in Golang with a step-by-step guide and code snippet.
package main
import (
"crypto/md5"
"fmt"
"io"
"os"
)
func main() {
h := md5.New()
io.WriteString(h, "The quick brown fox jumps over the lazy dog")
fmt.Printf("%x", h.Sum(nil))
}
This Golang code snippet demonstrates how to create an MD5 hash of a string. This is useful for many applications, like verifying data integrity or storing passwords.
The 'crypto/md5' package is imported which provides the algorithm for MD5 hash generation. The 'io' package is used for the WriteString function and the 'fmt' for printing the hash.
First, the MD5 hash generator is initialized with 'md5.New()'. Then, the string to be hashed ('The quick brown fox jumps over the lazy dog') is written to the hash generator with 'io.WriteString'.
Finally, the generated hash is converted to hexadecimal format and printed using 'fmt.Printf'. The '%x' format verb is used to convert the byte slice returned by 'h.Sum(nil)' to a hexadecimal string.