Struct xtsn::XTSN

source ·
pub struct XTSN { /* private fields */ }
Expand description

XTSN works the same as CXTSN, the only difference is, that the XTSN version is written in pure Rust and handles Errors. This means that the Result actually returns usefull stuff, that you should defenitly parse!

Implementations

initializes a new Cryptor it requires 2 keys:

  • crypt to decrypt
  • tweak to encrypt they can be the same but shouldn’t !!!

This function is used to encrypt data. It works only with buffers, that are a multiple of 0x200! The function doesn’t check the buffer so it will silently ignore any trailing bytes in the buffer!

Example
extern crate XTSN;

fn main() {
    let mut data = b"Hello XTSN".to_vec();
    // the string is not 0x200 bytes:
    while data.len() != 0x200 {
        data.push(0);
    }
    let xts = match XTSN::CXTSN::new("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
                                    "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") {
        Ok(res) => res,
        Err(e) => panic!(e),
    };
    let ret = match xts.encrypt(data, 0) {
        Ok(res) => res,
        Err(e) => panic!(e),
    };
    println!("{:?}", &ret);
}

This function is used to encrypt data. It works just only with buffers, that are a multiple of 0x200! The function doesn’t check the buffer so it will silently ignore any trailing bytes in the buffer! This function is currently broken and need some debugging, or you can just use the CXTSN version which just works :3

Example
extern crate XTSN;

fn main() {
    let mut data = b"Hello XTSN".to_vec();
    // the string is not 0x200 bytes:
    while data.len() != 0x200 {
        data.push(0);
    }
    let xts = match XTSN::XTSN::new("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
                                    "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") {
        Ok(res) => res,
        Err(e) => panic!(e),
    };
    let ret = match xts.encrypt(data, 0) {
        Ok(res) => res,
        Err(e) => panic!(e),
    };
    println!("{:?}", &ret);
}

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.