在Go语言中,`crypto.randomBytes(32)`在Node的crypto包中的等效方式是什么?

huangapple go评论82阅读模式
英文:

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

rand.Read:

import "crypto/rand"
…
b := make([]byte, 32)
_, err := rand.Read(b)
英文:

rand.Read:

import "crypto/rand"
…
b := make([]byte, 32)
_, err := rand.Read(b)

huangapple
  • 本文由 发表于 2015年8月23日 12:33:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/32163173.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定