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:
parent
9b1927f700
commit
1343bcdca6
2 changed files with 15 additions and 2 deletions
|
@ -8,7 +8,20 @@ use crate::blowfish_constants::{BLOWFISH_P, BLOWFISH_S};
|
||||||
const ROUNDS: usize = 16;
|
const ROUNDS: usize = 16;
|
||||||
const KEYBITS: u32 = 64u32 >> 3;
|
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 {
|
pub struct Blowfish {
|
||||||
p: [u32; 18],
|
p: [u32; 18],
|
||||||
s: [[u32; 256]; 4],
|
s: [[u32; 256]; 4],
|
||||||
|
|
|
@ -43,7 +43,7 @@ pub mod patch;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod macros;
|
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;
|
pub mod blowfish;
|
||||||
|
|
||||||
mod blowfish_constants;
|
mod blowfish_constants;
|
||||||
|
|
Loading…
Add table
Reference in a new issue