[][src]Struct codebreaker::Codebreaker

pub struct Codebreaker { /* fields omitted */ }

A processor for CB v1 and v7 codes.

Implementations

impl Codebreaker[src]

pub const fn new() -> Self[src]

Returns a new processor for encrypting and decrypting a list of CB v1 and v7 codes.

pub fn new_v7() -> Self[src]

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.

pub fn encrypt_code(&mut self, addr: u32, val: u32) -> (u32, u32)[src]

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!((0x2AFF014C, 0x2411FFFF), code);

pub fn encrypt_code_mut(&mut self, addr: &mut u32, val: &mut u32)[src]

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!((0x2AFF014C, 0x2411FFFF), code);

pub fn decrypt_code(&mut self, addr: u32, val: u32) -> (u32, u32)[src]

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!(decrypted[i], result);
}

pub fn decrypt_code_mut(&mut self, addr: &mut u32, val: &mut u32)[src]

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!(decrypted, encrypted);

pub fn auto_decrypt_code(&mut self, addr: u32, val: u32) -> (u32, u32)[src]

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!(output[i], cb.auto_decrypt_code(code.0, code.1));
}

pub fn auto_decrypt_code_mut(&mut self, addr: &mut u32, val: &mut u32)[src]

Smart version of decrypt_code_mut that detects if and how a code needs to be decrypted.

Trait Implementations

impl Clone for Codebreaker[src]

impl Copy for Codebreaker[src]

impl Debug for Codebreaker[src]

impl Default for Codebreaker[src]

Does the same as new.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.