From 1343bcdca607d7adb4525a20fcb08833a506a29a Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 22 Sep 2023 17:52:31 -0400 Subject: [PATCH] Expand Blowfish documentation, add example to doc --- src/blowfish.rs | 15 ++++++++++++++- src/lib.rs | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/blowfish.rs b/src/blowfish.rs index 747f00f..9b0e4b8 100755 --- a/src/blowfish.rs +++ b/src/blowfish.rs @@ -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], diff --git a/src/lib.rs b/src/lib.rs index 9b69fa8..e61e982 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -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;