[Solved] Porting MD5 from node.js to go [closed]


If you only need the standard md5 algorithm, here’s how to use it in go, as noted in the documentation:

import (
    "fmt"
    "crypto/md5"
    "io"
)

func main() {
    h := md5.New()
    io.WriteString(h, "The fog is getting thicker!")
    io.WriteString(h, "And Leon's getting laaarger!")
    fmt.Printf("%x", h.Sum(nil))
}

If you need an md5 function that returns a string, here’s how to do it:

func md5(input string) string {
    h := md5.New()
    io.WriteString(h, input)
    return fmt.Sprintf("%x", h.Sum(nil))
}

1

solved Porting MD5 from node.js to go [closed]