#random #byte #generate #csprng #bip-39 #alphabet #numeric

wasmium-random

生成随机数字、字母、字母数字、BIP39和EFF随机字节

1个稳定版本

1.0.0 2021年12月17日

#1436算法

每月35次下载
2 crates 中使用

CC0-1.0 OR Apache-2.0

205KB
9K SLoC

WasmiumRandom - 你的可爱 🤪 堆栈分配随机字节生成器

此crate使用nanorand crate从英文字母字符、字母数字字符和数字字符生成随机字节。

此crate不在堆上分配。任何堆分配都是错误,请在Github上提交问题。并行化计划在以后进行。

用法

导入crate

use wasmium_random::WasmiumRandom;

使用字母 a-z,A-Z 从CSPRNG安全地生成字节。这对于密码学应用很有用。

use wasmium_random::WasmiumRandom;

// Generate 12 random bytes
WasmiumRandom::secure_alphabet12();

// Generate 24 random bytes
WasmiumRandom::secure_alphabet24();

// Generate 32 random bytes
WasmiumRandom::secure_alphabet32();

// Generate 64 random bytes
WasmiumRandom::secure_alphabet64();

// Generate 128 random bytes
WasmiumRandom::secure_alphabet128();

// Generate 256 random bytes
WasmiumRandom::secure_alphabet256();

// Generate 512 random bytes
WasmiumRandom::secure_alphabet512();

使用字母数字字符 0-9,a-z,A-Z 从CSPRNG安全地生成字节。这对于密码学应用很有用。

use wasmium_random::WasmiumRandom;

// Generate 12 random bytes securely
WasmiumRandom::secure_alphanumeric12();

// Generate 24 random bytes securely
WasmiumRandom::secure_alphanumeric24();

// Generate 32 random bytes securely
WasmiumRandom::secure_alphanumeric32();

// Generate 64 random bytes securely
WasmiumRandom::secure_alphanumeric64();

// Generate 128 random bytes securely
WasmiumRandom::secure_alphanumeric128();

// Generate 512 random bytes securely
WasmiumRandom::secure_alphanumeric512();

使用数字字符 0-9 从CSPRNG安全地生成字节。这对于密码学应用很有用。

use wasmium_random::WasmiumRandom;

// Generate 12 random bytes securely
WasmiumRandom::secure_numeric12();

// Generate 24 random bytes securely
WasmiumRandom::secure_numeric24();

// Generate 32 random bytes securely
WasmiumRandom::secure_numeric32();

// Generate 64 random bytes securely
WasmiumRandom::secure_numeric64();

// Generate 128 random bytes securely
WasmiumRandom::secure_numeric128();

// Generate 512 random bytes securely
WasmiumRandom::secure_numeric512();

还支持使用超级快速的Wyrand PRNG生成非密码学安全的随机字节。

使用字母 a-z,A-Z 从PRNG生成字节。

use wasmium_random::WasmiumRandom;

// Generate 12 random bytes
WasmiumRandom::wyrand_alphabet12();

// Generate 24 random bytes
WasmiumRandom::wyrand_alphabet24();

// Generate 32 random bytes
WasmiumRandom::secure_alphabet32();

// Generate 64 random bytes
WasmiumRandom::wyrand_alphabet64();

// Generate 128 random bytes
WasmiumRandom::wyrand_alphabet128();

// Generate 256 random bytes
WasmiumRandom::wyrand_alphabet256();

// Generate 512 random bytes
WasmiumRandom::wyrand_alphabet512();

使用字母数字字符 0-9,a-z,A-Z 从PRNG生成字节。

use wasmium_random::WasmiumRandom;

// Generate 12 random bytes
WasmiumRandom::wyrand_alphanumeric12();

// Generate 24 random bytes
WasmiumRandom::wyrand_alphanumeric24();

// Generate 32 random bytes
WasmiumRandom::wyrand_alphanumeric32();

// Generate 64 random bytes
WasmiumRandom::wyrand_alphanumeric64();

// Generate 128 random bytes
WasmiumRandom::wyrand_alphanumeric128();

// Generate 512 random bytes
WasmiumRandom::wyrand_alphanumeric512();

使用数字字符 0-9 从PRNG生成字节。

use wasmium_random::WasmiumRandom;

// Generate 12 random bytes securely
WasmiumRandom::wyrand_numeric12();

// Generate 24 random bytes securely
WasmiumRandom::wyrand_numeric24();

// Generate 32 random bytes securely
WasmiumRandom::wyrand_numeric32();

// Generate 64 random bytes securely
WasmiumRandom::wyrand_numeric64();

// Generate 128 random bytes securely
WasmiumRandom::wyrand_numeric128();

// Generate 512 random bytes securely
WasmiumRandom::wyrand_numeric512();

注意::可以从字符生成最多2048字节的字节。请参阅子模块文档。

也支持BIP39、EFF短列表和EFF长列表的英文字母单词。

许可协议

CC0-1.0Apache-2.0

依赖项