golang中crypto/rand包

栏目: Go · 发布时间: 7年前

内容简介:rand包实现了用于加解密的更安全的随机数生成器。变量:var Reader io.Reader

rand包实现了用于加解密的更安全的随机数生成器。

变量:

var Reader io.Reader

Reader是一个全局、共享的密码用强随机生成器。在Unix类型系统中,会从/dev/urandom读取;而windows中会调用CryptGenRandom API。

func INt(rand io.Reader, max *big.Int) (n *big.Int, err error)

返回一个在[0, max)区间服从均匀分布的随机值,如果max <= 0则会panic。

func Prime(rand io.Reader, nit int) (p *big.Int, err error)

返回一个具体有指定指定字位数的数字,该数字具有很高可能是质素。如果从rand读取时出错,或者bits < 2 会返回错误。

func Read(b []byte) (n int, err error)

本函数时一个使用io.ReadFull调用Reader.Read的辅助性函数。当且仅当err == nil时,返回n==len(b)


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Web Applications (Hacking Exposed)

Web Applications (Hacking Exposed)

Joel Scambray、Mike Shema / McGraw-Hill Osborne Media / 2002-06-19 / USD 49.99

Get in-depth coverage of Web application platforms and their vulnerabilities, presented the same popular format as the international bestseller, Hacking Exposed. Covering hacking scenarios across diff......一起来看看 《Web Applications (Hacking Exposed)》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具