added partial content support (not supported with tagging rn), added content-length header (fixes super aids), updated dependencies
This commit is contained in:
parent
873e1002b9
commit
ea88be5762
7 changed files with 174 additions and 112 deletions
21
src/lib.rs
21
src/lib.rs
|
@ -1,20 +1,21 @@
|
|||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use aes::Aes128Enc;
|
||||
use blowfish::Blowfish;
|
||||
use aes::Aes128;
|
||||
use block_modes::{BlockMode, Cbc, Ecb};
|
||||
use block_modes::block_padding::{NoPadding, ZeroPadding};
|
||||
use md5::{Md5, Digest};
|
||||
use cipher::{
|
||||
BlockEncrypt, BlockDecryptMut, KeyInit, KeyIvInit,
|
||||
block_padding::{NoPadding, ZeroPadding}
|
||||
};
|
||||
|
||||
type BfCbc = Cbc<Blowfish, NoPadding>;
|
||||
type Aes128Ecb = Ecb<Aes128, ZeroPadding>;
|
||||
type BfCbcDec = cbc::Decryptor<Blowfish>;
|
||||
|
||||
const TRACK_CDN_KEY: [u8; 16] = [106, 111, 54, 97, 101, 121, 54, 104, 97, 105, 100, 50, 84, 101, 105, 104];
|
||||
const BF_SECRET: [u8; 16] = [103, 52, 101, 108, 53, 56, 119, 99, 48, 122, 118, 102, 57, 110, 97, 49];
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub struct Cipher {
|
||||
cipher: BfCbc
|
||||
cipher: BfCbcDec
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
|
@ -27,11 +28,11 @@ impl Cipher {
|
|||
for i in 0..16 {
|
||||
key[i] = id_md5[i] ^ id_md5[i+16] ^ BF_SECRET[i]
|
||||
};
|
||||
Self { cipher: BfCbc::new_from_slices(&key, &[0, 1, 2, 3, 4, 5, 6, 7]).unwrap() }
|
||||
Self { cipher: BfCbcDec::new_from_slices(&key, &[0, 1, 2, 3, 4, 5, 6, 7]).unwrap() }
|
||||
}
|
||||
|
||||
pub fn decrypt_chunk(&self, chunk: &mut [u8]) {
|
||||
self.cipher.clone().decrypt(chunk).unwrap();
|
||||
self.cipher.clone().decrypt_padded_mut::<NoPadding>(chunk).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,8 +59,8 @@ pub fn legacy_stream_url(md5_origin: &str, format: &str, id: &str, media_version
|
|||
&[b'\xa4'],
|
||||
].concat();
|
||||
|
||||
let cipher = Aes128Ecb::new_from_slices(&TRACK_CDN_KEY, Default::default()).unwrap();
|
||||
let ciphertext = cipher.encrypt_vec(&metadata_hash);
|
||||
let cipher = Aes128Enc::new_from_slice(&TRACK_CDN_KEY).unwrap();
|
||||
let ciphertext = cipher.encrypt_padded_vec::<ZeroPadding>(&metadata_hash);
|
||||
|
||||
format!("https://cdns-proxy-{}.dzcdn.net/mobile/1/{}", md5_origin.chars().next().unwrap(), hex::encode(ciphertext))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue