small optimization

This commit is contained in:
uh wot 2021-08-23 18:55:33 +02:00
parent 87d41408c6
commit 88447c3593
Signed by: uhwot
GPG Key ID: CB2454984587B781
4 changed files with 6 additions and 10 deletions

View File

@ -14,7 +14,6 @@ aes = "0.7"
md-5 = "0.9"
hex = "0.4"
js-sys = "0.3"
wasm-bindgen = "=0.2.74"
[dev-dependencies]

6
dist/worker.js vendored

File diff suppressed because one or more lines are too long

View File

@ -180,7 +180,7 @@ async function pipeDecryptedStream(writer, body, length, cipher) {
if (byteCount % 6144 === 0 && !end) {
// encrypted chunk
chunk = cipher.decrypt_chunk(chunk)
cipher.decrypt_chunk(chunk)
}
await writer.write(chunk)

View File

@ -1,7 +1,5 @@
use wasm_bindgen::prelude::*;
use js_sys::Uint8Array;
use blowfish::Blowfish;
use aes::Aes128;
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() }
}
pub fn decrypt_chunk(&self, chunk: &mut [u8]) -> Uint8Array {
let chunk = self.cipher.clone().decrypt(chunk).unwrap();
unsafe { Uint8Array::view(&chunk) }
pub fn decrypt_chunk(&self, chunk: &mut [u8]) {
self.cipher.clone().decrypt(chunk);
}
}