英文:
What would be the equivalent in Golang of crypto.randomBytes(32) in the Node crypto package?
问题
嗨,我会帮你翻译的。以下是要翻译的内容:
大家好,我基本上正在尝试重新创建这个Node.js包:
https://github.com/seishun/node-steam-crypto/blob/master/index.js
用golang
语言实现,这样我就可以对需要这些加密的sessionKeys
等内容进行Steam API的API调用。
我查看了crypto
包,但有很多不同的哈希方法可供使用,我不确定哪个方法最接近Node.js包中的crypto.randomBytes(32)
。
还有crypto.publicEncrypt()
。
如果这个问题问得不好,请原谅,因为我以前没有处理过这种东西。任何信息都将非常有帮助,谢谢。
英文:
Hi guys I'm basically trying to recreate this node package:
https://github.com/seishun/node-steam-crypto/blob/master/index.js
In golang
so I can make API calls to the Steam API that requires these encrypted sessionKeys
and what not.
I was looking through the crypto
package but there is so many different hashing methods to use I'm not sure which one would be the closest to the
crypto.randomBytes(32)
in the node package.
Also the
crypto.publicEncrypt()
Sorry if this question is crap, not sure how else to word it as I haven't really dealt with this kind of stuff before. Any information would be great thanks.
答案1
得分: 5
import "crypto/rand"
…
b := make([]byte, 32)
_, err := rand.Read(b)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论