英文:
What type of Reader to use when generating a Private Key in Go?
问题
我需要在Go中生成一个私钥。我正在使用rsa包(http://golang.org/pkg/crypto/rsa/)。特别是,我似乎想使用GenerateKey方法。该方法的一个参数是io.Reader类型(http://golang.org/pkg/io/#Reader),但似乎有许多不同类型的读取器。使用一种类型的Reader是否有任何优势?谢谢!
英文:
I need to generate a private key in Go. I am using the rsa package (http://golang.org/pkg/crypto/rsa/). In particular, it seems that I would like to use the GenerateKey method. One of the parameters for this method is of type io.Reader (http://golang.org/pkg/io/#Reader), but it seems like there are many different types of readers. Is there any advantage to using one type of Reader over another? Thanks!
答案1
得分: 5
我相信在这种特殊情况下,适合的io.Reader可能是crypto/rand.Reader。
var Reader io.Reader
Reader是一个全局共享的强加密伪随机生成器实例。在类Unix系统上,Reader从/dev/urandom读取。在Windows系统上,Reader使用CryptGenRandom API。
英文:
I believe that in this particular case the suitable io.Reader would be, for example, crypto/rand.Reader.
> var Reader io.Reader
>
>Reader is a global, shared instance of a cryptographically strong pseudo-random generator. On Unix-like systems, Reader reads from /dev/urandom. On Windows systems, Reader uses the CryptGenRandom API.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论