/// Export this [`RecoveryKey`] as an encrypted pickle that can be safely
/// stored.
Export this [`RecoveryKey`] as an encrypted pickle that can be safely
stored.
Export this [ ` RecoveryKey ` ] as an encrypted pickle that can be safely stored .
pub fn pickle(&self, pickle_key: &[u8]) -> PickledRecoveryKey {
        let key = GenericArray::from_slice(pickle_key);
        let cipher = Aes256Gcm::new(key);
        let mut nonce = vec![0u8; NONCE_SIZE];
        let mut rng = thread_rng();
        nonce.try_fill(&mut rng).expect("Can't generate random nocne to pickle the recovery key");
        let nonce = GenericArray::from_slice(nonce.as_slice());
        let ciphertext =
            cipher.encrypt(nonce, self.inner.as_ref()).expect("Can't encrypt recovery key");
        let ciphertext = encode_url_safe(ciphertext);
        let pickle =
            InnerPickle { version: 1, nonce: encode_url_safe(nonce.as_slice()), ciphertext };
        PickledRecoveryKey(serde_json::to_string(&pickle).expect("Can't encode pickled signing"))
    }
pub fn pickle ( & self , pickle_key : & [ u8 ] ) -> PickledRecoveryKey { let key = GenericArray :: from_slice ( pickle_key ) ; let cipher = Aes256Gcm :: new ( key ) ; let mut nonce = vec ! [ 0u8 NONCE_SIZE ] ; let mut rng = thread_rng ( ) ; nonce . try_fill ( & mut rng ) . expect ( " " ) ; let nonce = GenericArray :: from_slice ( nonce . as_slice ( ) ) ; let ciphertext = cipher . encrypt ( nonce , self . inner . as_ref ( ) ) . expect ( " " ) ; let ciphertext = encode_url_safe ( ciphertext ) ; let pickle = InnerPickle { version : 1 , nonce : encode_url_safe ( nonce . as_slice ( ) ) , ciphertext } ; PickledRecoveryKey ( serde_json :: to_string ( & pickle ) . expect ( " " ) ) }
Export this [`RecoveryKey`] as an encrypted pickle that can be safely
stored.
Export this [ ` RecoveryKey ` ] as an encrypted pickle that can be safely stored .
&self
pickle_key
&[u8]