sha256-hash-from-file

command
v0.0.0-...-a2a1f02 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2020 License: MIT Imports: 7 Imported by: 0

README

sha256-hash-from-file example

Get an sha256 hash (fingerprint) from an input file using the standard crypto/sha256 package.

Refer to the crypto/sha256 package for more info.

GitHub Webpage

RUN

go run sha256-hash-from-file.go <FILENAME>
go run sha256-hash-from-file.go test.txt

If you run on test.txt you should get,

7df64288ab2d0bcd15a9c78985965326d4b9d61202d1bc7b55b4abc89698c599

HOW IT WORKS

Take a string plainText and turn into a sha256 hash,

plainTextBytes := []byte(plainText)

// HASH
sha256HashByte := sha256.Sum256(plainTextBytes)

// CONVERT TO STRING
sha256Hash := hex.EncodeToString(sha256HashByte[:])

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL