[wasm] chore: use new key method

This commit is contained in:
鲁树人 2024-09-15 16:32:07 +01:00
parent 440df8a06b
commit 5432002253

View File

@ -19,8 +19,7 @@ impl JsQMC2 {
/// Create a new QMC2 (mgg/mflac) cipher instance. /// Create a new QMC2 (mgg/mflac) cipher instance.
#[wasm_bindgen(constructor)] #[wasm_bindgen(constructor)]
pub fn new(ekey: &str) -> Result<JsQMC2, JsError> { pub fn new(ekey: &str) -> Result<JsQMC2, JsError> {
let key = umc_qmc::ekey::decrypt(ekey).map_err(map_js_error)?; let cipher = QMCv2Cipher::new_from_ekey(ekey).map_err(map_js_error)?;
let cipher = QMCv2Cipher::new(key).map_err(map_js_error)?;
Ok(JsQMC2(cipher)) Ok(JsQMC2(cipher))
} }