1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-20 03:37:47 +00:00

Expand Blowfish documentation, add example to doc

This commit is contained in:
Joshua Goins 2023-09-22 17:52:31 -04:00
parent 9b1927f700
commit 1343bcdca6
2 changed files with 15 additions and 2 deletions

View file

@ -8,7 +8,20 @@ use crate::blowfish_constants::{BLOWFISH_P, BLOWFISH_S};
const ROUNDS: usize = 16;
const KEYBITS: u32 = 64u32 >> 3;
/// Implementation of the Blowfish block cipher, specialized for encrypting and decrypting SqexArg.
/// Implementation of the Blowfish block cipher, specialized for encrypting and decrypting SqexArg - the technique used to encrypt game arguments by the launcher.
///
/// # Example
///
/// ```
/// # use physis::blowfish::Blowfish;
/// let key = b"abcdefgh";
/// let data = b"foobar";
///
/// let fish = Blowfish::new(key);
/// let encrypted = fish.encrypt(data).unwrap();
/// let decrypted = fish.decrypt(&encrypted).unwrap();
/// # assert!(data == decrypted)
/// ```
pub struct Blowfish {
p: [u32; 18],
s: [[u32; 256]; 4],

View file

@ -43,7 +43,7 @@ pub mod patch;
#[macro_use]
mod macros;
/// Implementation of the Blowfish ECB block cipher used by the retail client.
/// Implementation of the Blowfish ECB block cipher used by the retail client. It's used to encrypt arguments in the launcher, to prevent login token snooping.
pub mod blowfish;
mod blowfish_constants;