mirror of
https://github.com/avelino/awesome-go.git
synced 2024-11-14 16:42:23 +00:00
31 lines
486 B
Go
31 lines
486 B
Go
package main
|
|
|
|
import (
|
|
"crypto/md5"
|
|
"crypto/sha1"
|
|
"crypto/sha256"
|
|
"crypto/sha512"
|
|
"fmt"
|
|
"os"
|
|
"log"
|
|
)
|
|
|
|
func main() {
|
|
|
|
/*
|
|
Hashing and Checksums
|
|
*/
|
|
|
|
// Get bytes from file
|
|
data, err := os.ReadFile("test.txt")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
// Hash the file and output results
|
|
fmt.Printf("Md5: %x\n\n", md5.Sum(data))
|
|
fmt.Printf("Sha1: %x\n\n", sha1.Sum(data))
|
|
fmt.Printf("Sha256: %x\n\n", sha256.Sum256(data))
|
|
fmt.Printf("Sha512: %x\n\n", sha512.Sum512(data))
|
|
}
|