Created
January 25, 2016 15:44
-
-
Save yangsibai/e7d2e752364b45982e5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"crypto/md5" | |
"crypto/sha1" | |
"crypto/sha256" | |
"crypto/sha512" | |
"encoding/hex" | |
"fmt" | |
"io" | |
"log" | |
"os" | |
"runtime" | |
) | |
func main() { | |
args := os.Args[1:] | |
var filename string | |
filename = args[0] | |
// open an io.Reader from the file we would like to calculate hashes | |
f, err := os.OpenFile(filename, os.O_RDONLY, 0) | |
if err != nil { | |
log.Fatalln("Cannot open file: %s", filename) | |
} | |
defer f.Close() | |
info := CalculateBasicHashes(f) | |
fmt.Println("md5 :", info.Md5) | |
fmt.Println("sha1 :", info.Sha1) | |
fmt.Println("sha256 :", info.Sha256) | |
fmt.Println("sha512 :", info.Sha512) | |
fmt.Println() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment