pub struct Turing { /* private fields */ }Implementations§
Source§impl Turing
impl Turing
Sourcepub fn new() -> Self
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}Sourcepub fn turing_key(
&mut self,
key: &[u8],
length: usize,
) -> Result<(), &'static str>
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}Sourcepub fn turing_iv(
&mut self,
iv: &[u8],
length: usize,
) -> Result<(), &'static str>
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}Sourcepub fn turing_gen(&mut self, buf: &mut [u8]) -> Result<usize, &'static str>
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> 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