I am learning the go language and write my first go program, with the help of some web sources:
package main
import (
"fmt"
"crypto/sha512"
"encoding/base64"
)
func main() {
ba := []byte("HelloWorld")
hasher := sha512.New()
hasher.Write(ba)
sha := base64.StdEncoding.EncodeToString(hasher.Sum(nil))
fmt.Printf(sha)
}
It compiles and works as expected, but I couldn't write this code myself since if i look at the Go package reference for sha256, I don't see the Write()
and the Sum()
methods. Where to find this kind of information? Maybe, I'm not reading the good document, or there is a sort of "inheritance" I didn't see.