Turing

Struct Turing 

Source
pub struct Turing { /* private fields */ }

Implementations§

Source§

impl Turing

Source

pub fn new() -> Self

Examples found in repository?
examples/turing_basic.rs (line 6)
3pub fn main() {
4    let key = b"test key 128bits";
5    let iv = b"";
6    let mut cipher = Turing::new();
7    let mut output = [0u8; 340];
8
9    cipher.turing_key(key, key.len()).unwrap();
10    cipher.turing_iv(iv, iv.len()).unwrap();
11    let n = cipher.turing_gen(&mut output).unwrap();
12
13    assert_eq!(n, 340);
14
15    println!("output: {:?}", output);
16}
Source

pub fn turing_key( &mut self, key: &[u8], length: usize, ) -> Result<(), &'static str>

设置密钥

Examples found in repository?
examples/turing_basic.rs (line 9)
3pub fn main() {
4    let key = b"test key 128bits";
5    let iv = b"";
6    let mut cipher = Turing::new();
7    let mut output = [0u8; 340];
8
9    cipher.turing_key(key, key.len()).unwrap();
10    cipher.turing_iv(iv, iv.len()).unwrap();
11    let n = cipher.turing_gen(&mut output).unwrap();
12
13    assert_eq!(n, 340);
14
15    println!("output: {:?}", output);
16}
Source

pub fn turing_iv( &mut self, iv: &[u8], length: usize, ) -> Result<(), &'static str>

设置初始化向量

Examples found in repository?
examples/turing_basic.rs (line 10)
3pub fn main() {
4    let key = b"test key 128bits";
5    let iv = b"";
6    let mut cipher = Turing::new();
7    let mut output = [0u8; 340];
8
9    cipher.turing_key(key, key.len()).unwrap();
10    cipher.turing_iv(iv, iv.len()).unwrap();
11    let n = cipher.turing_gen(&mut output).unwrap();
12
13    assert_eq!(n, 340);
14
15    println!("output: {:?}", output);
16}
Source

pub fn turing_gen(&mut self, buf: &mut [u8]) -> Result<usize, &'static str>

Generate a 340-byte buffer of cipher data. Return the number of bytes generated

Examples found in repository?
examples/turing_basic.rs (line 11)
3pub fn main() {
4    let key = b"test key 128bits";
5    let iv = b"";
6    let mut cipher = Turing::new();
7    let mut output = [0u8; 340];
8
9    cipher.turing_key(key, key.len()).unwrap();
10    cipher.turing_iv(iv, iv.len()).unwrap();
11    let n = cipher.turing_gen(&mut output).unwrap();
12
13    assert_eq!(n, 340);
14
15    println!("output: {:?}", output);
16}

Auto Trait Implementations§

§

impl Freeze for Turing

§

impl RefUnwindSafe for Turing

§

impl Send for Turing

§

impl Sync for Turing

§

impl Unpin for Turing

§

impl UnwindSafe for Turing

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.