Struct lockchain_core::crypto::Key [−][src]
pub struct Key { /* fields omitted */ }A crytographic key of a certain type
Uses a union to allow key inlining without heap allocation.
Provides easy to use constructors for generation and derivation
from user input/name.
Also implements serde::{Serialize, Deserialize} via a custom
serialiser which allows easy encryption of the key itself.
Methods
impl Key[src]
impl Keypub fn new(tt: KeyType) -> Key[src]
pub fn new(tt: KeyType) -> KeyGenerate a new, completely random key of a certain type
pub fn from_pw(tt: KeyType, pw: &str, user: &str) -> Key[src]
pub fn from_pw(tt: KeyType, pw: &str, user: &str) -> KeyGenerate a new key based on a user password
This function uses the pbkdf2 algorithm to deterministically expand an input pw/username combination into a key.
pub fn as_slice(&self) -> &[u8][src]
pub fn as_slice(&self) -> &[u8]Read the key as an imutable slice
pub fn as_mut_slice(&mut self) -> &mut [u8][src]
pub fn as_mut_slice(&mut self) -> &mut [u8]Read the key as a mutable slice
pub fn len(&self) -> usize[src]
pub fn len(&self) -> usizeReturn the length of the key in bytes
Trait Implementations
impl Serialize for Key[src]
impl Serialize for Keyfn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer, [src]
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer, Serialize this value into the given Serde serializer. Read more
impl Debug for Key[src]
impl Debug for Keyfn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>Formats the value using the given formatter. Read more
impl Eq for Key[src]
impl Eq for Keyimpl PartialEq<Key> for Key[src]
impl PartialEq<Key> for Keyfn eq(&self, o: &Key) -> bool[src]
fn eq(&self, o: &Key) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0[src]
fn ne(&self, other: &Rhs) -> boolThis method tests for !=.
impl<'de> Deserialize<'de> for Key[src]
impl<'de> Deserialize<'de> for Keyfn deserialize<D>(
deserializer: D
) -> Result<Key, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>, [src]
fn deserialize<D>(
deserializer: D
) -> Result<Key, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>, Deserialize this value from the given Serde deserializer. Read more
impl AutoEncoder for Key[src]
impl AutoEncoder for Keyfn encode(&self) -> Result<String, SerdeError>[src]
fn encode(&self) -> Result<String, SerdeError>fn decode(s: &str) -> Result<Self, SerdeError>[src]
fn decode(s: &str) -> Result<Self, SerdeError>