rand

package
v0.0.0-...-ebe581b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// int8 类型
	KeyLengthInt8 = 8

	// int16 类型
	KeyLengthInt16 = 16

	// int32 类型
	KeyLengthInt32 = 32

	// int64 类型
	KeyLengthInt64 = 64
)

定义不同int类型对应的key length

View Source
const (
	// 安全强度低
	KeyStrengthEasy = iota

	// 安全强度中
	KeyStrengthMiddle

	// 安全强度高
	KeyStrengthHard
)

Variables

View Source
var (
	// 熵的长度不在 [128, 256]以内或者长度不是32的倍数
	ErrInvalidEntropyLength = errors.New("entropy length must within [128, 256] and be multiples of 32")

	// 随机熵的强度暂未被支持
	ErrStrengthNotSupported = fmt.Errorf("strength required for generating Mnemonic has not been supported yet")
)

Functions

func GenerateEntropy

func GenerateEntropy(bitSize int) ([]byte, error)

GenerateEntropy 底层调用跟操作系统相关的函数(读取系统熵)来产生一些伪随机数, 对外建议管这个返回值叫做“熵”

func GenerateSeedWithStrengthAndKeyLen

func GenerateSeedWithStrengthAndKeyLen(strength int, keyLength int) ([]byte, error)

GenerateSeedWithStrengthAndKeyLen 生成指定强度和长度的随机熵

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL