You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package blockchainlib
import ( "crypto/sha256" "encoding/base64" "encoding/json" "log" )
func HashBlock(b Block) string { blockJson, err := json.Marshal(b) if err != nil { log.Println(err) } blockString := string(blockJson)
h := sha256.New() h.Write([]byte(blockString)) return base64.URLEncoding.EncodeToString(h.Sum(nil)) }
|