/// Given a sealed value `str` and a key name `name`, where the nonce is
/// prepended to the original value and then both are Base64 encoded,
/// verifies and decrypts the sealed value and returns it. If there's a
/// problem, returns an `Err` with a string describing the issue.
Given a sealed value `str` and a key name `name`, where the nonce is
prepended to the original value and then both are Base64 encoded,
verifies and decrypts the sealed value and returns it. If there's a
problem, returns an `Err` with a string describing the issue.
Given a sealed value ` str ` and a key name ` name ` where the nonce is prepended to the original value and then both are Base64 encoded verifies and decrypts the sealed value and returns it . If there ' s a problem returns an ` Err ` with a string describing the issue .
fn unseal(&self, name: &str, value: &str) -> Result<String, &'static str> {
        let mut data = base64::decode(value).map_err(|_| "bad base64 value")?;
        if data.len() <= NONCE_LEN {
            return Err("length of decoded data is <= NONCE_LEN");
        }
        let ad = Aad::from(name.as_bytes());
        let key = LessSafeKey::new(UnboundKey::new(&ALGO, &self.key).expect("matching key length"));
        let (nonce, mut sealed) = data.split_at_mut(NONCE_LEN);
        let nonce = Nonce::try_assume_unique_for_key(nonce)
            .expect("invalid length of `nonce`");
        let unsealed = key.open_in_place(nonce, ad, &mut sealed)
            .map_err(|_| "invalid key/nonce/value: bad seal")?;
        ::std::str::from_utf8(unsealed)
            .map(|s| s.to_string())
            .map_err(|_| "bad unsealed utf8")
    }
fn unseal ( & self , name : & str , value : & str ) -> Result < String , & ' static str > { let mut data = base64 :: decode ( value ) . map_err ( | _ | " " ) ? ; if data . len ( ) <= NONCE_LEN { return Err ( " " ) ; } let ad = Aad :: from ( name . as_bytes ( ) ) ; let key = LessSafeKey :: new ( UnboundKey :: new ( & ALGO , & self . key ) . expect ( " " ) ) ; let ( nonce , mut sealed ) = data . split_at_mut ( NONCE_LEN ) ; let nonce = Nonce :: try_assume_unique_for_key ( nonce ) . expect ( " " ) ; let unsealed = key . open_in_place ( nonce , ad , & mut sealed ) . map_err ( | _ | " " ) ? ; :: std :: str :: from_utf8 ( unsealed ) . map ( | s | s . to_string ( ) ) . map_err ( | _ | " " ) }
Given a sealed value `str` and a key name `name`, where the nonce is
prepended to the original value and then both are Base64 encoded,
verifies and decrypts the sealed value and returns it.
Given a sealed value ` str ` and a key name ` name ` where the nonce is prepended to the original value and then both are Base64 encoded verifies and decrypts the sealed value and returns it .
&self
name
&str
value
&str