Almost I got stuck in the js implementation of go lang hmac.New for several days. However, no success. I used crypto,crypto-js and stablelib modules for implementation. The problem is that in go lang version, hmac instance can be created by hmac instance. For example (the code block is correct and tested):
hmacf := hmac.New(func() hash.Hash {
return hmac.New(func() hash.Hash {
return hmac.New(func() hash.Hash {
return hmac.New(sha256.New, []byte(SALT))
}, []byte(path[0]))
}, []byte(path[1]))
}, []byte(path[2]))
Actually, I don't know how does it work! because in all javascript related modules, You can't create hmac from hmac, and they accept an string value that determines hashing algorithm.
maybe it's better to ask how to create hmac from hmac in javascript.
from hmac.New(h func() hash.Hash, key []byte) hash.Hash equivalent in javascript
No comments:
Post a Comment