small optimization
This commit is contained in:
parent
87d41408c6
commit
88447c3593
|
@ -14,7 +14,6 @@ aes = "0.7"
|
||||||
md-5 = "0.9"
|
md-5 = "0.9"
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
|
|
||||||
js-sys = "0.3"
|
|
||||||
wasm-bindgen = "=0.2.74"
|
wasm-bindgen = "=0.2.74"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
File diff suppressed because one or more lines are too long
2
index.js
2
index.js
|
@ -180,7 +180,7 @@ async function pipeDecryptedStream(writer, body, length, cipher) {
|
||||||
|
|
||||||
if (byteCount % 6144 === 0 && !end) {
|
if (byteCount % 6144 === 0 && !end) {
|
||||||
// encrypted chunk
|
// encrypted chunk
|
||||||
chunk = cipher.decrypt_chunk(chunk)
|
cipher.decrypt_chunk(chunk)
|
||||||
}
|
}
|
||||||
|
|
||||||
await writer.write(chunk)
|
await writer.write(chunk)
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
use js_sys::Uint8Array;
|
|
||||||
|
|
||||||
use blowfish::Blowfish;
|
use blowfish::Blowfish;
|
||||||
use aes::Aes128;
|
use aes::Aes128;
|
||||||
use block_modes::{BlockMode, Cbc, Ecb};
|
use block_modes::{BlockMode, Cbc, Ecb};
|
||||||
|
@ -32,9 +30,8 @@ impl Cipher {
|
||||||
Self { cipher: BfCbc::new_from_slices(&key, &[0, 1, 2, 3, 4, 5, 6, 7]).unwrap() }
|
Self { cipher: BfCbc::new_from_slices(&key, &[0, 1, 2, 3, 4, 5, 6, 7]).unwrap() }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decrypt_chunk(&self, chunk: &mut [u8]) -> Uint8Array {
|
pub fn decrypt_chunk(&self, chunk: &mut [u8]) {
|
||||||
let chunk = self.cipher.clone().decrypt(chunk).unwrap();
|
self.cipher.clone().decrypt(chunk);
|
||||||
unsafe { Uint8Array::view(&chunk) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue