在 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())
}
关于go - 在 Golang 中将 MD5 转换为十进制的最佳方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28128285/