music_dump_lib/ncm/
audio.rs

1use crate::NcmRc4;
2
3/// Decrypt audio in encrypted byte stream to decrypted byte stream that can be write into mp3
4/// use rc4 to decrypt the audio
5/// See [`NcmDecoder::decode`]
6pub struct Audio {
7    ncm_rc4: NcmRc4,
8    encrypted: Vec<u8>,
9}
10
11impl Audio {
12    pub fn new(ncm_rc4: NcmRc4, encrypted: Vec<u8>) -> Self {
13        Self {
14            ncm_rc4,
15            encrypted,
16        }
17    }
18
19    pub fn get_decrypted_audio(mut self) -> Vec<u8> {
20        self.ncm_rc4.decrypt(&mut self.encrypted);
21        self.encrypted
22    }
23}