Golang crypto/sha512 functions example
package crypto/sha512
Package sha512 implements the SHA384 and SHA512 hash algorithms as defined in FIPS 180-2.
Golang crypto/sha512 functions usage example
package main
import (
"crypto/sha512"
"fmt"
"io"
)
func main() {
h512 := sha512.New()
io.WriteString(h512, "Hello money money!")
fmt.Printf("Hash512 : %x\n", h512.Sum(nil))
h384 := sha512.New384()
io.WriteString(h384, "Hello money money!")
fmt.Printf("Hash384 : %x\n", h384.Sum(nil))
data := []byte("Hello World!")
fmt.Printf("SHA384 checksum : %x\n", sha512.Sum384(data))
fmt.Printf("SHA512 checksum : %x\n", sha512.Sum512(data))
}
Output :
Hash512 : 9a1d07713844cbb807f84658c0b1736d6e7a696ff25c444d0b3ae936ef5490451ac32722d8edcca404bbb4fa8d7aa7e97d9da87c5143ed6dcdf5a842a98dc457
Hash384 : 1ec2ec246873c5da50caeeb8025eaa52a9664db98a3dd0738a5651a3a55625d9f10f2e0b3433b204267862434e30d8f2
SHA384 checksum : bfd76c0ebbd006fee583410547c1887b0292be76d582d96c242d2a792723e3fd6fd061f9d5cfd13b8f961358e6adba4a
SHA512 checksum : 861844d6704e8573fec34d967e20bcfef3d424cf48be04e6dc08f2bd58c729743371015ead891cc3cf1c9d34b49264b510751b1ff9e537937bc46b5d6ff4ecc8
Reference :
Advertisement
Something interesting
Tutorials
+31.5k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+13.6k Golang : Set image canvas or background to transparent
+9k Golang : Populate or initialize struct with values example
+10.3k Golang : Detect number of faces or vehicles in a photo
+9.6k Golang : Quadratic example
+20.6k Nginx + FastCGI + Go Setup.
+30.4k Golang : How to redirect to new page with net/http?
+15k Golang : package is not in GOROOT during compilation
+10.9k Golang : Sieve of Eratosthenes algorithm
+19.9k Golang : How to get time from unix nano example
+27.7k PHP : Count number of JSON items/objects
+12.7k Golang : zlib compress file example