wasmium_random/lib.rs
1#![deny(missing_docs)]
2
3//! This crate uses the [nanorand](docs.rs/nanorand) crate to generate random bytes
4//! from the English alphabet characters, Alphanumeric characters and numeric characters.
5//!
6//! This crate does not allocate on the heap. Any heap allocation is a bug, please file an issue on Github.
7//! Parallelism is planned at a later date.
8//!
9//! ### Usage
10//! Import the crate
11//! ```
12//! use wasmium_random::WasmiumRandom;
13//! ```
14//!
15//! ### Generate bytes securely from a CSPRNG using the alphabet `a-z,A-Z`. This is useful for cryptographic applications.
16//! ```rust
17//! # use wasmium_random::WasmiumRandom;
18//!
19//! // Generate 12 random bytes
20//! WasmiumRandom::secure_alphabet12();
21//!
22//! // Generate 24 random bytes
23//! WasmiumRandom::secure_alphabet24();
24//!
25//! // Generate 32 random bytes
26//! WasmiumRandom::secure_alphabet32();
27//!
28//! // Generate 64 random bytes
29//! WasmiumRandom::secure_alphabet64();
30//!
31//! // Generate 128 random bytes
32//! WasmiumRandom::secure_alphabet128();
33//!
34//! // Generate 256 random bytes
35//! WasmiumRandom::secure_alphabet256();
36//!
37//! // Generate 512 random bytes
38//! WasmiumRandom::secure_alphabet512();
39//! ```
40//!
41//! ### Generate bytes securely from a CSPRNG using the alphanumeric characters `0-9,a-z,A-Z`. This is useful for cryptographic applications.
42//! ```rust
43//! # use wasmium_random::WasmiumRandom;
44//!
45//! // Generate 12 random bytes securely
46//! WasmiumRandom::secure_alphanumeric12();
47//!
48//! // Generate 24 random bytes securely
49//! WasmiumRandom::secure_alphanumeric24();
50//!
51//! // Generate 32 random bytes securely
52//! WasmiumRandom::secure_alphanumeric32();
53//!
54//! // Generate 64 random bytes securely
55//! WasmiumRandom::secure_alphanumeric64();
56//!
57//! // Generate 128 random bytes securely
58//! WasmiumRandom::secure_alphanumeric128();
59//!
60//! // Generate 512 random bytes securely
61//! WasmiumRandom::secure_alphanumeric512();
62//! ```
63//!
64//! ### Generate bytes securely from a CSPRNG using the numeric characters `0-9`. This is useful for cryptographic applications.
65//! ```rust
66//! # use wasmium_random::WasmiumRandom;
67//!
68//! // Generate 12 random bytes securely
69//! WasmiumRandom::secure_numeric12();
70//!
71//! // Generate 24 random bytes securely
72//! WasmiumRandom::secure_numeric24();
73//!
74//! // Generate 32 random bytes securely
75//! WasmiumRandom::secure_numeric32();
76//!
77//! // Generate 64 random bytes securely
78//! WasmiumRandom::secure_numeric64();
79//!
80//! // Generate 128 random bytes securely
81//! WasmiumRandom::secure_numeric128();
82//!
83//! // Generate 512 random bytes securely
84//! WasmiumRandom::secure_numeric512();
85//! ```
86//!
87//!
88//! ## Non-cryptographically secure random bytes are also supported using the super fast [Wyrand](nanorand::WyRand) PRNG.
89//! ### Generate bytes from a PRNG using the alphabet `a-z,A-Z`.
90//! ```rust
91//! # use wasmium_random::WasmiumRandom;
92//!
93//! // Generate 12 random bytes
94//! WasmiumRandom::wyrand_alphabet12();
95//!
96//! // Generate 24 random bytes
97//! WasmiumRandom::wyrand_alphabet24();
98//!
99//! // Generate 32 random bytes
100//! WasmiumRandom::secure_alphabet32();
101//!
102//! // Generate 64 random bytes
103//! WasmiumRandom::wyrand_alphabet64();
104//!
105//! // Generate 128 random bytes
106//! WasmiumRandom::wyrand_alphabet128();
107//!
108//! // Generate 256 random bytes
109//! WasmiumRandom::wyrand_alphabet256();
110//!
111//! // Generate 512 random bytes
112//! WasmiumRandom::wyrand_alphabet512();
113//! ```
114//!
115//! ### Generate bytes from a PRNG using the alphanumeric characters `0-9,a-z,A-Z`.
116//! ```rust
117//! # use wasmium_random::WasmiumRandom;
118//!
119//! // Generate 12 random bytes
120//! WasmiumRandom::wyrand_alphanumeric12();
121//!
122//! // Generate 24 random bytes
123//! WasmiumRandom::wyrand_alphanumeric24();
124//!
125//! // Generate 32 random bytes
126//! WasmiumRandom::wyrand_alphanumeric32();
127//!
128//! // Generate 64 random bytes
129//! WasmiumRandom::wyrand_alphanumeric64();
130//!
131//! // Generate 128 random bytes
132//! WasmiumRandom::wyrand_alphanumeric128();
133//!
134//! // Generate 512 random bytes
135//! WasmiumRandom::wyrand_alphanumeric512();
136//! ```
137//!
138//! ### Generate bytes from a PRNG using the numeric characters `0-9`.
139//! ```
140//! # use wasmium_random::WasmiumRandom;
141//!
142//! // Generate 12 random bytes securely
143//! WasmiumRandom::wyrand_numeric12();
144//!
145//! // Generate 24 random bytes securely
146//! WasmiumRandom::wyrand_numeric24();
147//!
148//! // Generate 32 random bytes securely
149//! WasmiumRandom::wyrand_numeric32();
150//!
151//! // Generate 64 random bytes securely
152//! WasmiumRandom::wyrand_numeric64();
153//!
154//! // Generate 128 random bytes securely
155//! WasmiumRandom::wyrand_numeric128();
156//!
157//! // Generate 512 random bytes securely
158//! WasmiumRandom::wyrand_numeric512();
159//!
160//! ```
161//! `NOTE:` The bytes from characters can be generated to upto 2048 bytes. See the submodule
162//! documentation.
163//!
164//! The BIP39, EFF shortlist and EFF largelist of English alphabet words are also supported.
165//!
166mod common;
167pub use common::*;
168
169mod csprng;
170pub use csprng::*;
171
172mod prng;
173pub use prng::*;
174
175mod wordlists;
176pub use wordlists::*;