pub struct CXTSN { /* private fields */ }
Expand description
This structure is the C-Version of the XTSN decryptor It works the same way the XTSN version does!
Implementations
sourceimpl CXTSN
impl CXTSN
sourcepub fn new(crypt: &str, tweak: &str) -> Result<Self, String>
pub fn new(crypt: &str, tweak: &str) -> Result<Self, String>
initializes a new Cryptor it requires 2 keys:
- crypt to decrypt
- tweak to encrypt they can be the same but shouldn’t !!!
sourcepub fn encrypt(
&self,
buffer: Vec<u8>,
sector_off: usize
) -> Result<Vec<u8>, String>
pub fn encrypt(
&self,
buffer: Vec<u8>,
sector_off: usize
) -> Result<Vec<u8>, String>
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);
}
sourcepub fn decrypt(
&self,
buffer: Vec<u8>,
sector_off: usize
) -> Result<Vec<u8>, String>
pub fn decrypt(
&self,
buffer: Vec<u8>,
sector_off: usize
) -> Result<Vec<u8>, String>
This function is used to decrypt 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! 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::CXTSN::new("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") {
Ok(res) => res,
Err(e) => panic!(e),
};
let ret = match xts.decrypt(data, 0) {
Ok(res) => res,
Err(e) => panic!(e),
};
println!("{:?}", &ret);
}
Auto Trait Implementations
impl RefUnwindSafe for CXTSN
impl Send for CXTSN
impl Sync for CXTSN
impl Unpin for CXTSN
impl UnwindSafe for CXTSN
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more