在执行密码哈希时,我有以下node.js代码。
body.password = covid@19
salt = "hello@world"
body.passwordhex = crypto.createHmac('sha256', salt).update(body.password).digest('hex');它给出了以下结果:
5fbbff7f6b4db4df6308c6ad7e8fd5afcea513bb70ca12073c7bec618c6b4959
现在,我试图把它转换成go-lang的等价物,我的代码是
body_password := "covid@19“
salt := "hello@world"
// Create a new HMAC by defining the hash type and the key (as byte array)
h := hmac.New(sha256.New, []byte(key))
// Write Data to it
h.Write([]byte(salt))
// Get result and encode as hexadecimal string
hash := hex.EncodeToString(h.Sum(nil))而去朗的结果是
9b0cb661fcea1bbfe1fa38912e8610f8c0e4707739021988006368c1ba8da8b7
我的格朗密码有什么问题吗?是文摘吗?
发布于 2020-05-02 16:00:17
Javascript代码使用salt作为HMAC键,并对body_password进行散列。在Go中做同样的事情以获得同样的结果:
body_password := "covid@19"
salt := "hello@world"
h := hmac.New(sha256.New, []byte(salt))
h.Write([]byte(body_password))
hash := hex.EncodeToString(h.Sum(nil))在GoLang PlayGround:https://play.golang.org/p/GASMDhEhqGi上运行程序
https://stackoverflow.com/questions/61562230
复制相似问题