pub fn nacl_secret_box(
    _context: std::sync::Arc<ClientContext>,
    params: ParamsOfNaclSecretBox,
) -> ClientResult<ResultOfNaclBox> {
    let (mut padded_output, padded_input, nonce, key) = prepare_to_convert(
        &base64_decode(&params.decrypted)?,
        &hex_decode(&params.nonce)?,
        &hex_decode(&params.key)?,
        32,
    )?;

    sodalite::secretbox(&mut padded_output, &padded_input, &nonce, &key)
        .map_err(|_| crypto::Error::nacl_secret_box_failed("secret box failed"))?;
    padded_output.drain(..16);
    Ok(ResultOfNaclBox {
        encrypted: base64::encode(&padded_output),
    })
}
/// Encrypt and authenticate message using nonce and secret key.
Encrypt and authenticate message using nonce and secret key.
Encrypt and authenticate message using nonce and secret key .
pub fn nacl_secret_box(
    _context: std::sync::Arc<ClientContext>,
    params: ParamsOfNaclSecretBox,
) -> ClientResult<ResultOfNaclBox> {
    let (mut padded_output, padded_input, nonce, key) = prepare_to_convert(
        &base64_decode(&params.decrypted)?,
        &hex_decode(&params.nonce)?,
        &hex_decode(&params.key)?,
        32,
    )?;
    sodalite::secretbox(&mut padded_output, &padded_input, &nonce, &key)
        .map_err(|_| crypto::Error::nacl_secret_box_failed("secret box failed"))?;
    padded_output.drain(..16);
    Ok(ResultOfNaclBox {
        encrypted: base64::encode(&padded_output),
    })
}
pub fn nacl_secret_box ( _context : std :: sync :: Arc < ClientContext > , params : ParamsOfNaclSecretBox , ) -> ClientResult < ResultOfNaclBox > { let ( mut padded_output , padded_input , nonce , key ) = prepare_to_convert ( & base64_decode ( & params . decrypted ) ? , & hex_decode ( & params . nonce ) ? , & hex_decode ( & params . key ) ? , 32 , ) ? ; sodalite :: secretbox ( & mut padded_output , & padded_input , & nonce , & key ) . map_err ( | _ | crypto :: Error :: nacl_secret_box_failed ( " " ) ) ? ; padded_output . drain ( .. 16 ) ; Ok ( ResultOfNaclBox { encrypted : base64 :: encode ( & padded_output ) , } ) }
Encrypt and authenticate message using nonce and secret key.
Encrypt and authenticate message using nonce and secret key .
_context
std::sync::Arc<ClientContext>
params
ParamsOfNaclSecretBox