Add HachukanoCrypt (untested)

This commit is contained in:
2026-05-04 10:15:42 +08:00
parent c9949e8ef5
commit 0a9e0ff0a7
3 changed files with 45 additions and 0 deletions

View File

@@ -217,6 +217,10 @@ impl ChainReactionCrypt {
inner: Box::new(ChainReactionCryptBase::new("plugin/list.bin".into())),
}
}
fn new_inner(base: BaseSchema, inner: Box<dyn IChainReactionCrypt + Send + Sync>) -> Self {
Self { base, inner }
}
}
impl AsRef<BaseSchema> for ChainReactionCrypt {
@@ -279,3 +283,35 @@ impl<R: Read> Read for ChainReactionCryptReader<R> {
Ok(readed)
}
}
#[derive(Debug)]
pub struct HachukanoCrypt {
base: ChainReactionCryptBase,
}
impl HachukanoCrypt {
pub fn new(base: BaseSchema) -> ChainReactionCrypt {
ChainReactionCrypt::new_inner(
base,
Box::new(Self {
base: ChainReactionCryptBase::new("plugins/list.txt".into()),
}),
)
}
}
impl IChainReactionCrypt for HachukanoCrypt {
fn get_encryption_limit(&self, entry: &Xp3Entry) -> u32 {
let limit = self.base.get_encryption_limit(entry);
match limit {
0 => 0,
1 => 0x100,
2 => 0x200,
3 => entry.original_size as u32,
_ => limit,
}
}
fn init(&self, archive: &mut Xp3Archive) -> Result<()> {
self.base.init(archive)
}
}

View File

@@ -267,6 +267,7 @@ enum CryptType {
layer_name_suffix: String,
},
ChainReactionCrypt,
HachukanoCrypt,
}
#[derive(Clone, Debug, Deserialize)]
@@ -432,6 +433,9 @@ impl Schema {
CryptType::ChainReactionCrypt => {
Box::new(chain_reaction::ChainReactionCrypt::new(self.base.clone()))
}
CryptType::HachukanoCrypt => {
Box::new(chain_reaction::HachukanoCrypt::new(self.base.clone()))
}
})
}
}