mirror of
https://git.um-react.app/um/lib_um_crypto_rust.git
synced 2026-03-08 04:29:54 +00:00
[kgm] refactor: convert to enum for dispatch
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::header::Header;
|
||||
use crate::{Decipher, KugouError};
|
||||
use crate::KugouError;
|
||||
|
||||
pub struct DecipherV3 {
|
||||
slot_key: [u8; 16],
|
||||
@@ -30,11 +30,9 @@ impl DecipherV3 {
|
||||
let offset_key = (offset as u32).to_ne_bytes();
|
||||
offset_key[0] ^ offset_key[1] ^ offset_key[2] ^ offset_key[3]
|
||||
}
|
||||
}
|
||||
|
||||
impl Decipher for DecipherV3 {
|
||||
fn decrypt(&self, buffer: &mut [u8], offset: usize) {
|
||||
for (datum, offset) in buffer.iter_mut().zip(offset..) {
|
||||
pub fn decrypt<T: AsMut<[u8]> + ?Sized>(&self, buffer: &mut T, offset: usize) {
|
||||
for (datum, offset) in buffer.as_mut().iter_mut().zip(offset..) {
|
||||
let offset_key = Self::offset_key(offset);
|
||||
|
||||
let file_key = self.file_key[offset % self.file_key.len()];
|
||||
|
||||
Reference in New Issue
Block a user