pub struct AesRng(/* private fields */);
Expand description
This uses AES in a counter-mode-esque way, but with the counter always starting at zero. When used as a PRNG this is okay [TODO: citation?].
Implementations§
Trait Implementations§
source§impl From<AesRngCore> for AesRng
impl From<AesRngCore> for AesRng
source§fn from(core: AesRngCore) -> Self
fn from(core: AesRngCore) -> Self
Converts to this type from the input type.
source§impl RngCore for AesRng
impl RngCore for AesRng
source§fn fill_bytes(&mut self, dest: &mut [u8])
fn fill_bytes(&mut self, dest: &mut [u8])
Fill
dest
with random data. Read moresource§impl SeedableRng for AesRng
impl SeedableRng for AesRng
§type Seed = <AesRngCore as SeedableRng>::Seed
type Seed = <AesRngCore as SeedableRng>::Seed
Seed type, which is restricted to types mutably-dereferenceable as
u8
arrays (we recommend [u8; N]
for some N
). Read moresource§fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error>
fn from_rng<R: RngCore>(rng: R) -> Result<Self, Error>
Create a new PRNG seeded from another
Rng
. Read moresource§fn seed_from_u64(state: u64) -> Self
fn seed_from_u64(state: u64) -> Self
Create a new PRNG using a
u64
seed. Read moresource§fn from_entropy() -> Self
fn from_entropy() -> Self
impl CryptoRng for AesRng
Auto Trait Implementations§
impl Freeze for AesRng
impl RefUnwindSafe for AesRng
impl Send for AesRng
impl Sync for AesRng
impl Unpin for AesRng
impl UnwindSafe for AesRng
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Conv for T
impl<T> Conv for T
source§impl<T> CryptoRngCore for T
impl<T> CryptoRngCore for T
source§fn as_rngcore(&mut self) -> &mut dyn RngCore
fn as_rngcore(&mut self) -> &mut dyn RngCore
Upcast to an
RngCore
trait object.§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R> RandBigInt for R
impl<R> RandBigInt for R
source§fn gen_biguint(&mut self, bit_size: u64) -> BigUint
fn gen_biguint(&mut self, bit_size: u64) -> BigUint
Generate a random
BigUint
of the given bit size.source§fn gen_bigint(&mut self, bit_size: u64) -> BigInt
fn gen_bigint(&mut self, bit_size: u64) -> BigInt
Generate a random BigInt` of the given bit size.
source§fn gen_biguint_below(&mut self, bound: &BigUint) -> BigUint
fn gen_biguint_below(&mut self, bound: &BigUint) -> BigUint
Generate a random
BigUint
less than the given bound. Fails
when the bound is zero.§impl<R> RandPrime<BigUint> for Rwhere
R: Rng,
impl<R> RandPrime<BigUint> for Rwhere
R: Rng,
§fn gen_prime(
&mut self,
bit_size: usize,
config: Option<PrimalityTestConfig>
) -> BigUint
fn gen_prime( &mut self, bit_size: usize, config: Option<PrimalityTestConfig> ) -> BigUint
Generate a random prime within the given bit size limit Read more
§fn gen_prime_exact(
&mut self,
bit_size: usize,
config: Option<PrimalityTestConfig>
) -> BigUint
fn gen_prime_exact( &mut self, bit_size: usize, config: Option<PrimalityTestConfig> ) -> BigUint
Generate a random prime with exact the given bit size Read more
§fn gen_safe_prime(&mut self, bit_size: usize) -> BigUint
fn gen_safe_prime(&mut self, bit_size: usize) -> BigUint
Generate a random (Sophie German) safe prime within the given bit size limit. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
§fn gen_safe_prime_exact(&mut self, bit_size: usize) -> BigUint
fn gen_safe_prime_exact(&mut self, bit_size: usize) -> BigUint
Generate a random (Sophie German) safe prime with the exact given bit size. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
§impl<R> RandPrime<u128> for Rwhere
R: Rng,
impl<R> RandPrime<u128> for Rwhere
R: Rng,
§fn gen_prime(
&mut self,
bit_size: usize,
config: Option<PrimalityTestConfig>
) -> u128
fn gen_prime( &mut self, bit_size: usize, config: Option<PrimalityTestConfig> ) -> u128
Generate a random prime within the given bit size limit Read more
§fn gen_prime_exact(
&mut self,
bit_size: usize,
config: Option<PrimalityTestConfig>
) -> u128
fn gen_prime_exact( &mut self, bit_size: usize, config: Option<PrimalityTestConfig> ) -> u128
Generate a random prime with exact the given bit size Read more
§fn gen_safe_prime(&mut self, bit_size: usize) -> u128
fn gen_safe_prime(&mut self, bit_size: usize) -> u128
Generate a random (Sophie German) safe prime within the given bit size limit. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
§fn gen_safe_prime_exact(&mut self, bit_size: usize) -> u128
fn gen_safe_prime_exact(&mut self, bit_size: usize) -> u128
Generate a random (Sophie German) safe prime with the exact given bit size. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
§impl<R> RandPrime<u16> for Rwhere
R: Rng,
impl<R> RandPrime<u16> for Rwhere
R: Rng,
§fn gen_prime(&mut self, bit_size: usize, _: Option<PrimalityTestConfig>) -> u16
fn gen_prime(&mut self, bit_size: usize, _: Option<PrimalityTestConfig>) -> u16
Generate a random prime within the given bit size limit Read more
§fn gen_prime_exact(
&mut self,
bit_size: usize,
_: Option<PrimalityTestConfig>
) -> u16
fn gen_prime_exact( &mut self, bit_size: usize, _: Option<PrimalityTestConfig> ) -> u16
Generate a random prime with exact the given bit size Read more
§fn gen_safe_prime(&mut self, bit_size: usize) -> u16
fn gen_safe_prime(&mut self, bit_size: usize) -> u16
Generate a random (Sophie German) safe prime within the given bit size limit. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
§fn gen_safe_prime_exact(&mut self, bit_size: usize) -> u16
fn gen_safe_prime_exact(&mut self, bit_size: usize) -> u16
Generate a random (Sophie German) safe prime with the exact given bit size. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
§impl<R> RandPrime<u32> for Rwhere
R: Rng,
impl<R> RandPrime<u32> for Rwhere
R: Rng,
§fn gen_prime(&mut self, bit_size: usize, _: Option<PrimalityTestConfig>) -> u32
fn gen_prime(&mut self, bit_size: usize, _: Option<PrimalityTestConfig>) -> u32
Generate a random prime within the given bit size limit Read more
§fn gen_prime_exact(
&mut self,
bit_size: usize,
_: Option<PrimalityTestConfig>
) -> u32
fn gen_prime_exact( &mut self, bit_size: usize, _: Option<PrimalityTestConfig> ) -> u32
Generate a random prime with exact the given bit size Read more
§fn gen_safe_prime(&mut self, bit_size: usize) -> u32
fn gen_safe_prime(&mut self, bit_size: usize) -> u32
Generate a random (Sophie German) safe prime within the given bit size limit. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
§fn gen_safe_prime_exact(&mut self, bit_size: usize) -> u32
fn gen_safe_prime_exact(&mut self, bit_size: usize) -> u32
Generate a random (Sophie German) safe prime with the exact given bit size. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
§impl<R> RandPrime<u64> for Rwhere
R: Rng,
impl<R> RandPrime<u64> for Rwhere
R: Rng,
§fn gen_prime(&mut self, bit_size: usize, _: Option<PrimalityTestConfig>) -> u64
fn gen_prime(&mut self, bit_size: usize, _: Option<PrimalityTestConfig>) -> u64
Generate a random prime within the given bit size limit Read more
§fn gen_prime_exact(
&mut self,
bit_size: usize,
_: Option<PrimalityTestConfig>
) -> u64
fn gen_prime_exact( &mut self, bit_size: usize, _: Option<PrimalityTestConfig> ) -> u64
Generate a random prime with exact the given bit size Read more
§fn gen_safe_prime(&mut self, bit_size: usize) -> u64
fn gen_safe_prime(&mut self, bit_size: usize) -> u64
Generate a random (Sophie German) safe prime within the given bit size limit. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
§fn gen_safe_prime_exact(&mut self, bit_size: usize) -> u64
fn gen_safe_prime_exact(&mut self, bit_size: usize) -> u64
Generate a random (Sophie German) safe prime with the exact given bit size. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
§impl<R> RandPrime<u8> for Rwhere
R: Rng,
impl<R> RandPrime<u8> for Rwhere
R: Rng,
§fn gen_prime(&mut self, bit_size: usize, _: Option<PrimalityTestConfig>) -> u8
fn gen_prime(&mut self, bit_size: usize, _: Option<PrimalityTestConfig>) -> u8
Generate a random prime within the given bit size limit Read more
§fn gen_prime_exact(
&mut self,
bit_size: usize,
_: Option<PrimalityTestConfig>
) -> u8
fn gen_prime_exact( &mut self, bit_size: usize, _: Option<PrimalityTestConfig> ) -> u8
Generate a random prime with exact the given bit size Read more
§fn gen_safe_prime(&mut self, bit_size: usize) -> u8
fn gen_safe_prime(&mut self, bit_size: usize) -> u8
Generate a random (Sophie German) safe prime within the given bit size limit. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
§fn gen_safe_prime_exact(&mut self, bit_size: usize) -> u8
fn gen_safe_prime_exact(&mut self, bit_size: usize) -> u8
Generate a random (Sophie German) safe prime with the exact given bit size. The generated prime
is guaranteed to pass the [is_safe_prime][crate::nt_funcs::is_safe_prime] test Read more
source§impl<R> Rng for R
impl<R> Rng for R
source§fn gen<T>(&mut self) -> Twhere
Standard: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
Standard: Distribution<T>,
source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Generate a random value in the given range. Read more
source§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Sample a new value, using the given distribution. Read more
source§fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Create an iterator that generates values using the given distribution. Read more
source§fn gen_bool(&mut self, p: f64) -> bool
fn gen_bool(&mut self, p: f64) -> bool
Return a bool with a probability
p
of being true. Read moresource§fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool
Return a bool with a probability of
numerator/denominator
of being
true. I.e. gen_ratio(2, 3)
has chance of 2 in 3, or about 67%, of
returning true. If numerator == denominator
, then the returned value
is guaranteed to be true
. If numerator == 0
, then the returned
value is guaranteed to be false
. Read more§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.