Struct secstr::SecStr
[−]
[src]
pub struct SecStr { /* fields omitted */ }A data type suitable for storing sensitive information such as passwords and private keys in memory, that implements:
- Automatic zeroing in
Drop - Constant time comparison in
PartialEq(does not short circuit on the first different character; but terminates instantly if strings have different length) - Outputting
***SECRET***to prevent leaking secrets into logs infmt::Debugandfmt::Display - Automatic
mlockto protect against leaking into swap
Be careful with SecStr::from: if you have a borrowed string, it will be copied.
Use SecStr::new if you have a Vec<u8>.
Methods
impl SecStr[src]
fn new(cont: Vec<u8>) -> SecStr
fn unsecure(&self) -> &[u8]
Borrow the contents of the string.
fn unsecure_mut(&mut self) -> &mut [u8]
Mutably borrow the contents of the string.
fn zero_out(&mut self)
Overwrite the string with zeros. This is automatically called in the destructor.
Trait Implementations
impl Clone for SecStr[src]
fn clone(&self) -> SecStr
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more
impl<T> From<T> for SecStr where T: Into<Vec<u8>>[src]
impl Borrow<[u8]> for SecStr[src]
impl BorrowMut<[u8]> for SecStr[src]
fn borrow_mut(&mut self) -> &mut [u8]
Mutably borrows from an owned value. Read more
impl Drop for SecStr[src]
impl PartialEq for SecStr[src]
fn eq(&self, other: &SecStr) -> bool
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0
This method tests for !=.