A Rust library to decrypt & encrypt any cheat code for CodeBreaker PS2.
Add the crate as a dependency to your Cargo.toml:
[dependencies]
codebreaker = "0.4"Now you can start decrypting some codes:
use codebreaker::Codebreaker;
let input: Vec<(u32, u32)> = vec![
(0x2043AFCC, 0x2411FFFF),
(0x2A973DBD, 0x00000000),
(0xB4336FA9, 0x4DFEFB79),
(0x973E0B2A, 0xA7D4AF10),
];
let output: Vec<(u32, u32)> = vec![
(0x2043AFCC, 0x2411FFFF),
(0x201F6024, 0x00000000),
(0xBEEFC0DE, 0x00000000),
(0x2096F5B8, 0x000000BE),
];
let mut cb = Codebreaker::new();
for (i, code) in input.iter().enumerate() {
assert_eq!(cb.auto_decrypt_code(code.0, code.1), output[i]);
}Read the full documentation for more examples.
The codebreaker crate is no_std, has no dependencies, and supports both little- and big-endian targets.
The CB v7 implementation intentionally preserves byte-level behavior from the original C code.
- 2006: I cracked the CodeBreaker PS2 v7 code encryption by reverse-engineering MIPS R5900 assembly and converting it to C. I decrypted the first v7 codes on March 8 and released CB2crypt, a Windows tool built on that code, on March 23.
- 2007: Released cb2util in April, built on the same code, and extended it until 2013 to handle CodeBreaker's file formats.
- 2020: Ported the code to Rust for fun and profit and published it as this crate. I wrote about it in 7 Things I Learned From Porting a C Crypto Library to Rust.
- 2026: Checked against the real CodeBreaker v9.2 and v10 firmware with Claude Code and Opus 5.5, and fixed the bugs that turned up. The same year, I rewrote CB2crypt in Rust on top of this crate, twenty years after the Windows original.
Copyright (c) Mathias Lafeldt
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.