fn encrypt_url_safe(input: &[u8], config: &Config) -> Result<String, Error> {
    let cipher = ChaCha20Poly1305::new(&config.encryption_key);

    let nonce = rand::random::<[u8; NONCE_LEN]>();
    let nonce = ChaCha20Poly1305Nonce::from_slice(&nonce);

    let mut ciphertext = cipher.encrypt(nonce, input)?;
    ciphertext.extend_from_slice(nonce);

    Ok(base64::encode_config(&ciphertext, base64::URL_SAFE_NO_PAD))
}
// Encrypts the given string using ChaCha20Poly1305 and returns a url safe base64 encoded
// version of it
Encrypts the given string using ChaCha20Poly1305 and returns a url safe base64 encoded
version of it
Encrypts the given string using ChaCha20Poly1305 and returns a url safe base64 encoded version of it
fn encrypt_url_safe(input: &[u8], config: &Config) -> Result<String, Error> {
    let cipher = ChaCha20Poly1305::new(&config.encryption_key);
    let nonce = rand::random::<[u8; NONCE_LEN]>();
    let nonce = ChaCha20Poly1305Nonce::from_slice(&nonce);
    let mut ciphertext = cipher.encrypt(nonce, input)?;
    ciphertext.extend_from_slice(nonce);
    Ok(base64::encode_config(&ciphertext, base64::URL_SAFE_NO_PAD))
}
fn encrypt_url_safe ( input : & [ u8 ] , config : & Config ) -> Result < String , Error > { let cipher = ChaCha20Poly1305 :: new ( & config . encryption_key ) ; let nonce = rand :: random :: < [ u8 ; NONCE_LEN ] > ( ) ; let nonce = ChaCha20Poly1305Nonce :: from_slice ( & nonce ) ; let mut ciphertext = cipher . encrypt ( nonce , input ) ? ; ciphertext . extend_from_slice ( nonce ) ; Ok ( base64 :: encode_config ( & ciphertext , base64 :: URL_SAFE_NO_PAD ) ) }
Encrypts the given string using ChaCha20Poly1305 and returns a url safe base64 encoded
version of it
Encrypts the given string using ChaCha20Poly1305 and returns a url safe base64 encoded version of it
input
&[u8]
config
&Config
input
&[u8]
config
&Config