在 Golang 中将 MD5 转换为十进制的最佳方法?

Best way to convert an MD5 to decimal in Golang?

在Python我能做到

int(hashlib.md5('hello world').hexdigest(), 16)

结果是

125893641179230474042701625388361764291L

Golang 中获取 MD5 字符串并获得十进制表示的等价物是什么?

您可以使用 math/big 执行此操作。

package main

import (
    "crypto/md5"
    "encoding/hex"
    "fmt"
    "math/big"
)

func main() {
    bi := big.NewInt(0)
    h := md5.New()
    h.Write([]byte("hello world"))
    hexstr := hex.EncodeToString(h.Sum(nil))
    bi.SetString(hexstr, 16)
    fmt.Println(bi.String())
}

http://play.golang.org/p/3h521Ao1UY