The hash, or so-called checksum, is the easiest way to quickly compare any content. This recipe demonstrates how to create the checksum of the file content. For demonstration purposes, the MD5 hash function will be used.
Generating checksums
How to do it...
- Open the console and create the folder chapter03/recipe12.
- Navigate to the directory.
- Create the content.dat file with the following content:
This is content to check
- Create the checksum.go file with the following content:
package main
import (
"crypto/md5"
"fmt"
"io"
"os"
)
var content = "This is content to check"
func main() {
...