#[must_use]
pub struct SecretKey { /* fields omitted */ }
A type to represent a secret key.
As default it will randomly generate a SecretKey
of 32 bytes.
Due to the return type of the Default trait, the default()
method cannot let the caller
handle a failing CSPRNG. If the CSPRNG fails, that function panics. If handling a failing CSPRNG's
error is needed, use instead generate()
.
An exception will be thrown if:
slice
is empty.
- The
OsRng
fails to initialize or read from its source.
length
is 0.
length
is not less than u32::max_value()
.
- Avoid using
unprotected_as_bytes()
whenever possible, as it breaks all protections
that the type implements.
Make an object from a given byte slice.
Return the object as byte slice. Warning: Should not be used unless strictly
needed. This breaks protections that the type implements.
Return the length of the object.
Randomly generate using a CSPRNG. Not available in no_std
context.
Executes the destructor for this type. Read more
Randomly generate using a CSPRNG with recommended size. Not available in no_std
context.
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Completely overwrites this value.
Called to initialize a place to a valid value, after it is set to all-bits-zero. Read more