Skip to content

Commit

Permalink
added missing docs (openethereum#5452)
Browse files Browse the repository at this point in the history
  • Loading branch information
svyatonik authored and tomusdrw committed Apr 13, 2017
1 parent 1e6674f commit 1df30ee
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ethstore/src/account/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@ impl From<Crypto> for String {
}

impl Crypto {
/// Encrypt account secret
pub fn with_secret(secret: &Secret, password: &str, iterations: u32) -> Self {
Crypto::with_plain(&*secret, password, iterations)
}

/// Encrypt custom plain data
pub fn with_plain(plain: &[u8], password: &str, iterations: u32) -> Self {
let salt: [u8; 32] = Random::random();
let iv: [u8; 16] = Random::random();
Expand Down Expand Up @@ -113,6 +115,7 @@ impl Crypto {
}
}

/// Try to decrypt and convert result to account secret
pub fn secret(&self, password: &str) -> Result<Secret, Error> {
if self.ciphertext.len() > 32 {
return Err(Error::InvalidSecret);
Expand All @@ -122,6 +125,7 @@ impl Crypto {
Ok(Secret::from_slice(&secret)?)
}

/// Try to decrypt and return result as is
pub fn decrypt(&self, password: &str) -> Result<Vec<u8>, Error> {
let expected_len = self.ciphertext.len();
self.do_decrypt(password, expected_len)
Expand Down

0 comments on commit 1df30ee

Please sign in to comment.