pub struct Codebreaker { /* private fields */ }Expand description
A processor for CB v1 and v7 codes.
Implementations§
Source§impl Codebreaker
impl Codebreaker
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Returns a new processor for encrypting and decrypting a list of CB v1 and v7 codes.
Sourcepub fn new_v7() -> Self
pub fn new_v7() -> Self
Returns a new processor for all CB v7 codes published on CMGSCCC.com.
Lets you omit B4336FA9 4DFEFB79 as the first code in the list.
Sourcepub fn encrypt_code(&mut self, addr: u32, val: u32) -> (u32, u32)
pub fn encrypt_code(&mut self, addr: u32, val: u32) -> (u32, u32)
Encrypts a code and returns the result.
§Example
use codebreaker::Codebreaker;
let mut cb = Codebreaker::new();
let code = cb.encrypt_code(0x2043AFCC, 0x2411FFFF);
assert_eq!(code, (0x2AFF014C, 0x2411FFFF));Sourcepub fn encrypt_code_mut(&mut self, addr: &mut u32, val: &mut u32)
pub fn encrypt_code_mut(&mut self, addr: &mut u32, val: &mut u32)
Encrypts a code directly.
§Example
use codebreaker::Codebreaker;
let mut cb = Codebreaker::new();
let mut code = (0x2043AFCC, 0x2411FFFF);
cb.encrypt_code_mut(&mut code.0, &mut code.1);
assert_eq!(code, (0x2AFF014C, 0x2411FFFF));Sourcepub fn decrypt_code(&mut self, addr: u32, val: u32) -> (u32, u32)
pub fn decrypt_code(&mut self, addr: u32, val: u32) -> (u32, u32)
Decrypts a code and returns the result.
§Example
use codebreaker::Codebreaker;
let encrypted: Vec<(u32, u32)> = vec![
(0x2AFF014C, 0x2411FFFF),
(0xB4336FA9, 0x4DFEFB79),
(0x973E0B2A, 0xA7D4AF10),
];
let decrypted: Vec<(u32, u32)> = vec![
(0x2043AFCC, 0x2411FFFF),
(0xBEEFC0DE, 0x00000000),
(0x2096F5B8, 0x000000BE),
];
let mut cb = Codebreaker::new();
for (i, code) in encrypted.iter().enumerate() {
let result = cb.decrypt_code(code.0, code.1);
assert_eq!(result, decrypted[i]);
}Sourcepub fn decrypt_code_mut(&mut self, addr: &mut u32, val: &mut u32)
pub fn decrypt_code_mut(&mut self, addr: &mut u32, val: &mut u32)
Decrypts a code directly.
§Example
use codebreaker::Codebreaker;
let mut encrypted: Vec<(u32, u32)> = vec![
(0x2AFF014C, 0x2411FFFF),
(0xB4336FA9, 0x4DFEFB79),
(0x973E0B2A, 0xA7D4AF10),
];
let decrypted: Vec<(u32, u32)> = vec![
(0x2043AFCC, 0x2411FFFF),
(0xBEEFC0DE, 0x00000000),
(0x2096F5B8, 0x000000BE),
];
let mut cb = Codebreaker::new();
for code in encrypted.iter_mut() {
cb.decrypt_code_mut(&mut code.0, &mut code.1);
}
assert_eq!(encrypted, decrypted);Sourcepub fn auto_decrypt_code(&mut self, addr: u32, val: u32) -> (u32, u32)
pub fn auto_decrypt_code(&mut self, addr: u32, val: u32) -> (u32, u32)
Smart version of decrypt_code that detects if
and how a code needs to be decrypted.
§Example
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]);
}Sourcepub fn auto_decrypt_code_mut(&mut self, addr: &mut u32, val: &mut u32)
pub fn auto_decrypt_code_mut(&mut self, addr: &mut u32, val: &mut u32)
Smart version of decrypt_code_mut that
detects if and how a code needs to be decrypted.
Trait Implementations§
Source§impl Clone for Codebreaker
impl Clone for Codebreaker
Source§fn clone(&self) -> Codebreaker
fn clone(&self) -> Codebreaker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Codebreaker
impl Debug for Codebreaker
Source§impl Default for Codebreaker
Does the same as new.
impl Default for Codebreaker
Does the same as new.
impl Copy for Codebreaker
Auto Trait Implementations§
impl Freeze for Codebreaker
impl RefUnwindSafe for Codebreaker
impl Send for Codebreaker
impl Sync for Codebreaker
impl Unpin for Codebreaker
impl UnwindSafe for Codebreaker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more