scryptenc_wasm/
encrypt.rs1use scryptenc::scrypt::Params;
8use wasm_bindgen::{JsError, prelude::wasm_bindgen};
9
10#[must_use]
15#[wasm_bindgen]
16pub fn encrypt(plaintext: &[u8], passphrase: &[u8]) -> Vec<u8> {
17 scryptenc::encrypt(plaintext, passphrase)
18}
19
20#[allow(clippy::module_name_repetitions)]
21#[wasm_bindgen(js_name = encryptWithParams)]
28pub fn encrypt_with_params(
29 plaintext: &[u8],
30 passphrase: &[u8],
31 log_n: u8,
32 r: u32,
33 p: u32,
34) -> Result<Vec<u8>, JsError> {
35 let params = Params::new(log_n, r, p, Params::RECOMMENDED_LEN)?;
36 Ok(scryptenc::encrypt_with_params(
37 plaintext, passphrase, params,
38 ))
39}