1#![allow(missing_docs)]
10#![allow(unused_must_use)]
11#![allow(dead_code)]
12#![allow(unused_imports)]
13#![allow(non_snake_case)]
14
15
16pub fn main()
23{
24 bigcryptor64_encrypt_with_padding_iso_ecb();
25 bigcryptor64_encrypt_with_padding_iso_ecb_into_vec();
26 bigcryptor64_encrypt_with_padding_iso_ecb_into_array();
27 bigcryptor64_encrypt_str_with_padding_iso_ecb();
28 bigcryptor64_encrypt_str_with_padding_iso_ecb_into_vec();
29 bigcryptor64_encrypt_str_with_padding_iso_ecb_into_array();
30 bigcryptor64_encrypt_string_with_padding_iso_ecb();
31 bigcryptor64_encrypt_string_with_padding_iso_ecb_into_vec();
32 bigcryptor64_encrypt_string_with_padding_iso_ecb_into_array();
33 bigcryptor64_encrypt_vec_with_padding_iso_ecb();
34 bigcryptor64_encrypt_vec_with_padding_iso_ecb_into_vec();
35 bigcryptor64_encrypt_vec_with_padding_iso_ecb_into_array();
36 bigcryptor64_encrypt_array_with_padding_iso_ecb();
37 bigcryptor64_encrypt_array_with_padding_iso_ecb_into_vec();
38 bigcryptor64_encrypt_array_with_padding_iso_ecb_into_array();
39
40 bigcryptor64_decrypt_with_padding_iso_ecb();
41 bigcryptor64_decrypt_with_padding_iso_ecb_into_vec();
42 bigcryptor64_decrypt_with_padding_iso_ecb_into_array();
43 bigcryptor64_decrypt_with_padding_iso_ecb_into_string();
44 bigcryptor64_decrypt_vec_with_padding_iso_ecb();
45 bigcryptor64_decrypt_vec_with_padding_iso_ecb_into_vec();
46 bigcryptor64_decrypt_vec_with_padding_iso_ecb_into_array();
47 bigcryptor64_decrypt_vec_with_padding_iso_ecb_into_string();
48 bigcryptor64_decrypt_array_with_padding_iso_ecb();
49 bigcryptor64_decrypt_array_with_padding_iso_ecb_into_vec();
50 bigcryptor64_decrypt_array_with_padding_iso_ecb_into_array();
51 bigcryptor64_decrypt_array_with_padding_iso_ecb_into_string();
52}
53
54fn bigcryptor64_encrypt_with_padding_iso_ecb()
55{
56 println!("bigcryptor64_encrypt_with_padding_iso_ecb()");
57 use std::io::Write;
58 use std::fmt::Write as _;
59 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
60
61 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
63 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
64 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
65 let message = "In the beginning God created the heavens and the earth.";
66 println!("M =\t{}", message);
67 let mut cipher = [0_u8; 56];
68 tdes.encrypt(message.as_ptr(), message.len() as u64, cipher.as_mut_ptr());
69 print!("C =\t");
70 for c in cipher.clone()
71 { print!("{:02X} ", c); }
72 println!();
73 let mut txt = String::new();
74 for c in cipher.clone()
75 { write!(txt, "{:02X} ", c); }
76 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
77 println!("-------------------------------");
78}
79
80fn bigcryptor64_encrypt_with_padding_iso_ecb_into_vec()
81{
82 println!("bigcryptor64_encrypt_with_padding_iso_ecb_into_vec()");
83 use std::io::Write;
84 use std::fmt::Write as _;
85 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
86
87 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
89 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
90 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
91 let message = "In the beginning God created the heavens and the earth.";
92 println!("M =\t{}", message);
93 let mut cipher = Vec::<u8>::new();
94 tdes.encrypt_into_vec(message.as_ptr(), message.len() as u64, &mut cipher);
95 print!("C =\t");
96 for c in cipher.clone()
97 { print!("{:02X} ", c); }
98 println!();
99 let mut txt = String::new();
100 for c in cipher.clone()
101 { write!(txt, "{:02X} ", c); }
102 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
103 println!("-------------------------------");
104}
105
106fn bigcryptor64_encrypt_with_padding_iso_ecb_into_array()
107{
108 println!("bigcryptor64_encrypt_with_padding_iso_ecb_into_array()");
109 use std::io::Write;
110 use std::fmt::Write as _;
111 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
112
113 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
115 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
116 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
117 let message = "In the beginning God created the heavens and the earth.";
118 println!("M =\t{}", message);
119 let mut cipher = [0_u8; 56];
120 tdes.encrypt_into_array(message.as_ptr(), message.len() as u64, &mut cipher);
121 print!("C =\t");
122 for c in cipher.clone()
123 { print!("{:02X} ", c); }
124 println!();
125 let mut txt = String::new();
126 for c in cipher.clone()
127 { write!(txt, "{:02X} ", c); }
128 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
129 println!("-------------------------------");
130}
131
132fn bigcryptor64_encrypt_str_with_padding_iso_ecb()
133{
134 println!("bigcryptor64_encrypt_str_with_padding_iso_ecb()");
135 use std::io::Write;
136 use std::fmt::Write as _;
137 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
138
139 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
141 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
142 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
143 let message = "In the beginning God created the heavens and the earth.";
144 println!("M =\t{}", message);
145 let mut cipher = [0_u8; 56];
146 tdes.encrypt_str(&message, cipher.as_mut_ptr());
147 print!("C =\t");
148 for c in cipher.clone()
149 { print!("{:02X} ", c); }
150 println!();
151 let mut txt = String::new();
152 for c in cipher.clone()
153 { write!(txt, "{:02X} ", c); }
154 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
155 println!("-------------------------------");
156}
157
158fn bigcryptor64_encrypt_str_with_padding_iso_ecb_into_vec()
159{
160 println!("bigcryptor64_encrypt_str_with_padding_iso_ecb_into_vec()");
161 use std::io::Write;
162 use std::fmt::Write as _;
163 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
164
165 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
167 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
168 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
169 let message = "In the beginning God created the heavens and the earth.";
170 let mut cipher = Vec::<u8>::new();
171 tdes.encrypt_str_into_vec(&message, &mut cipher);
172 print!("C =\t");
173 for c in cipher.clone()
174 { print!("{:02X} ", c); }
175 println!();
176 let mut txt = String::new();
177 for c in cipher.clone()
178 { write!(txt, "{:02X} ", c); }
179 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
180 println!("-------------------------------");
181}
182
183fn bigcryptor64_encrypt_str_with_padding_iso_ecb_into_array()
184{
185 println!("bigcryptor64_encrypt_str_with_padding_iso_ecb_into_array()");
186 use std::io::Write;
187 use std::fmt::Write as _;
188 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
189
190 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
192 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
193 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
194 let message = "In the beginning God created the heavens and the earth.";
195 let mut cipher = [0_u8; 56];
196 tdes.encrypt_str_into_array(&message, &mut cipher);
197 print!("C =\t");
198 for c in cipher.clone()
199 { print!("{:02X} ", c); }
200 println!();
201 let mut txt = String::new();
202 for c in cipher.clone()
203 { write!(txt, "{:02X} ", c); }
204 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
205 println!("-------------------------------");
206}
207
208fn bigcryptor64_encrypt_string_with_padding_iso_ecb()
209{
210 println!("bigcryptor64_encrypt_string_with_padding_iso_ecb()");
211 use std::io::Write;
212 use std::fmt::Write as _;
213 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
214
215 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
217 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
218 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
219 let message = "In the beginning God created the heavens and the earth.".to_string();
220 let mut cipher = [0_u8; 56];
221 tdes.encrypt_string(&message, cipher.as_mut_ptr());
222 print!("C =\t");
223 for c in cipher.clone()
224 { print!("{:02X} ", c); }
225 println!();
226 let mut txt = String::new();
227 for c in cipher.clone()
228 { write!(txt, "{:02X} ", c); }
229 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
230 println!("-------------------------------");
231}
232
233fn bigcryptor64_encrypt_string_with_padding_iso_ecb_into_vec()
234{
235 println!("bigcryptor64_encrypt_string_with_padding_iso_ecb_into_vec()");
236 use std::io::Write;
237 use std::fmt::Write as _;
238 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
239
240 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
242 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
243 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
244 let message = "In the beginning God created the heavens and the earth.".to_string();
245 let mut cipher = Vec::<u8>::new();
246 tdes.encrypt_string_into_vec(&message, &mut cipher);
247 print!("C =\t");
248 for c in cipher.clone()
249 { print!("{:02X} ", c); }
250 println!();
251 let mut txt = String::new();
252 for c in cipher.clone()
253 { write!(txt, "{:02X} ", c); }
254 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
255 println!("-------------------------------");
256}
257
258fn bigcryptor64_encrypt_string_with_padding_iso_ecb_into_array()
259{
260 println!("bigcryptor64_encrypt_string_with_padding_iso_ecb_into_array()");
261 use std::io::Write;
262 use std::fmt::Write as _;
263 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
264
265 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
267 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
268 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
269 let message = "In the beginning God created the heavens and the earth.".to_string();
270 let mut cipher = [0_u8; 56];
271 tdes.encrypt_string_into_array(&message, &mut cipher);
272 print!("C =\t");
273 for c in cipher.clone()
274 { print!("{:02X} ", c); }
275 println!();
276 let mut txt = String::new();
277 for c in cipher.clone()
278 { write!(txt, "{:02X} ", c); }
279 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
280 println!("-------------------------------");
281}
282
283fn bigcryptor64_encrypt_vec_with_padding_iso_ecb()
284{
285 println!("bigcryptor64_encrypt_vec_with_padding_iso_ecb()");
286 use std::io::Write;
287 use std::fmt::Write as _;
288 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
289
290 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
292 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
293 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
294 let message = "In the beginning God created the heavens and the earth.";
295 println!("M =\t{}", message);
296 let message = unsafe { message.to_string().as_mut_vec().clone() };
297 let mut cipher = [0_u8; 56];
298 tdes.encrypt_vec(&message, cipher.as_mut_ptr());
299 print!("C =\t");
300 for c in cipher.clone()
301 { print!("{:02X} ", c); }
302 println!();
303 let mut txt = String::new();
304 for c in cipher.clone()
305 { write!(txt, "{:02X} ", c); }
306 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
307 println!("-------------------------------");
308}
309
310fn bigcryptor64_encrypt_vec_with_padding_iso_ecb_into_vec()
311{
312 println!("bigcryptor64_encrypt_vec_with_padding_iso_ecb_into_vec()");
313 use std::io::Write;
314 use std::fmt::Write as _;
315 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
316
317 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
319 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
320 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
321 let message = "In the beginning God created the heavens and the earth.";
322 println!("M =\t{}", message);
323 let message = unsafe { message.to_string().as_mut_vec().clone() };
324 let mut cipher = Vec::<u8>::new();
325 tdes.encrypt_vec_into_vec(&message, &mut cipher);
326 print!("C =\t");
327 for c in cipher.clone()
328 { print!("{:02X} ", c); }
329 println!();
330 let mut txt = String::new();
331 for c in cipher.clone()
332 { write!(txt, "{:02X} ", c); }
333 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
334 println!("-------------------------------");
335}
336
337fn bigcryptor64_encrypt_vec_with_padding_iso_ecb_into_array()
338{
339 println!("bigcryptor64_encrypt_vec_with_padding_iso_ecb_into_array()");
340 use std::io::Write;
341 use std::fmt::Write as _;
342 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
343
344 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
346 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
347 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
348 let message = "In the beginning God created the heavens and the earth.";
349 println!("M =\t{}", message);
350 let message = unsafe { message.to_string().as_mut_vec().clone() };
351 let mut cipher = [0_u8; 56];
352 tdes.encrypt_vec_into_array(&message, &mut cipher);
353 print!("C =\t");
354 for c in cipher.clone()
355 { print!("{:02X} ", c); }
356 println!();
357 let mut txt = String::new();
358 for c in cipher.clone()
359 { write!(txt, "{:02X} ", c); }
360 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
361 println!("-------------------------------");
362}
363
364fn bigcryptor64_encrypt_array_with_padding_iso_ecb()
365{
366 println!("bigcryptor64_encrypt_array_with_padding_iso_ecb()");
367 use std::io::Write;
368 use std::fmt::Write as _;
369 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
370
371 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
373 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
374 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
375 let mes = "In the beginning God created the heavens and the earth.";
376 println!("M =\t{}", mes);
377 let mut message = [0_u8; 55];
378 message.copy_from_slice(unsafe { mes.to_string().as_mut_vec() });
379 let mut cipher = [0_u8; 56];
380 tdes.encrypt_array(&message, cipher.as_mut_ptr());
381 print!("C =\t");
382 for c in cipher.clone()
383 { print!("{:02X} ", c); }
384 println!();
385 let mut txt = String::new();
386 for c in cipher.clone()
387 { write!(txt, "{:02X} ", c); }
388 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
389 println!("-------------------------------");
390}
391
392fn bigcryptor64_encrypt_array_with_padding_iso_ecb_into_vec()
393{
394 println!("bigcryptor64_encrypt_array_with_padding_iso_ecb_into_vec()");
395 use std::io::Write;
396 use std::fmt::Write as _;
397 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
398
399 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
401 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
402 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
403 let mes = "In the beginning God created the heavens and the earth.";
404 println!("M =\t{}", mes);
405 let mut message = [0_u8; 55];
406 message.copy_from_slice(unsafe { mes.to_string().as_mut_vec() });
407 let mut cipher = Vec::<u8>::new();
408 tdes.encrypt_array_into_vec(&message, &mut cipher);
409 print!("C =\t");
410 for c in cipher.clone()
411 { print!("{:02X} ", c); }
412 println!();
413 let mut txt = String::new();
414 for c in cipher.clone()
415 { write!(txt, "{:02X} ", c); }
416 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
417 println!("-------------------------------");
418}
419
420fn bigcryptor64_encrypt_array_with_padding_iso_ecb_into_array()
421{
422 println!("bigcryptor64_encrypt_array_with_padding_iso_ecb_into_array()");
423 use std::io::Write;
424 use std::fmt::Write as _;
425 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
426
427 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
429 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
430 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
431 let mes = "In the beginning God created the heavens and the earth.";
432 println!("M =\t{}", mes);
433 let mut message = [0_u8; 55];
434 message.copy_from_slice(unsafe { mes.to_string().as_mut_vec() });
435 let mut cipher = [0_u8; 56];
436 tdes.encrypt_array_into_array(&message, &mut cipher);
437 for c in cipher.clone()
438 { print!("{:02X} ", c); }
439 println!();
440 let mut txt = String::new();
441 for c in cipher.clone()
442 { write!(txt, "{:02X} ", c); }
443 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
444 println!("-------------------------------");
445}
446
447fn bigcryptor64_decrypt_with_padding_iso_ecb()
448{
449 println!("bigcryptor64_decrypt_with_padding_iso_ecb()");
450 use std::io::Write;
451 use std::fmt::Write as _;
452 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
453
454 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
456 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
457 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
458 let message = "In the beginning God created the heavens and the earth.";
459 println!("M =\t{}", message);
460 let mut cipher = Vec::<u8>::new();
461 tdes.encrypt_str_into_vec(&message, &mut cipher);
462 print!("C =\t");
463 for c in cipher.clone()
464 { print!("{:02X} ", c); }
465 println!();
466 let mut txt = String::new();
467 for c in cipher.clone()
468 { write!(txt, "{:02X} ", c); }
469 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
470
471 let mut recovered = vec![0; 55];
472 tdes.decrypt(cipher.as_ptr(), cipher.len() as u64, recovered.as_mut_ptr());
473 print!("Ba =\t");
474 for b in recovered.clone()
475 { print!("{:02X} ", b); }
476 println!();
477 let mut txt = String::new();
478 for c in recovered.clone()
479 { write!(txt, "{:02X} ", c); }
480 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
481
482 let mut converted = String::new();
483 unsafe { converted.as_mut_vec() }.append(&mut recovered);
484
485 println!("Bb =\t{}", converted);
486 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
487 assert_eq!(converted, message);
488 println!("-------------------------------");
489}
490
491fn bigcryptor64_decrypt_with_padding_iso_ecb_into_vec()
492{
493 println!("bigcryptor64_decrypt_with_padding_iso_ecb_into_vec()");
494 use std::io::Write;
495 use std::fmt::Write as _;
496 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
497
498 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
500 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
501 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
502 let message = "In the beginning God created the heavens and the earth.";
503 println!("M =\t{}", message);
504 let mut cipher = Vec::<u8>::new();
505 tdes.encrypt_str_into_vec(&message, &mut cipher);
506 print!("C =\t");
507 for c in cipher.clone()
508 { print!("{:02X} ", c); }
509 println!();
510 let mut txt = String::new();
511 for c in cipher.clone()
512 { write!(txt, "{:02X} ", c); }
513 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
514
515 let mut recovered = Vec::<u8>::new();
516 tdes.decrypt_into_vec(cipher.as_ptr(), cipher.len() as u64, &mut recovered);
517 print!("Ba =\t");
518 for b in recovered.clone()
519 { print!("{:02X} ", b); }
520 println!();
521 let mut txt = String::new();
522 for c in recovered.clone()
523 { write!(txt, "{:02X} ", c); }
524 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
525
526 let mut converted = String::new();
527 unsafe { converted.as_mut_vec() }.append(&mut recovered);
528
529 println!("Bb =\t{}", converted);
530 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
531 assert_eq!(converted, message);
532 println!("-------------------------------");
533}
534
535fn bigcryptor64_decrypt_with_padding_iso_ecb_into_array()
536{
537 println!("bigcryptor64_decrypt_with_padding_iso_ecb_into_array()");
538 use std::io::Write;
539 use std::fmt::Write as _;
540 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
541
542 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
544 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
545 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
546 let message = "In the beginning God created the heavens and the earth.";
547 println!("M =\t{}", message);
548 let mut cipher = Vec::<u8>::new();
549 tdes.encrypt_str_into_vec(&message, &mut cipher);
550 print!("C =\t");
551 for c in cipher.clone()
552 { print!("{:02X} ", c); }
553 println!();
554 let mut txt = String::new();
555 for c in cipher.clone()
556 { write!(txt, "{:02X} ", c); }
557 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
558
559 let mut recovered = [0u8; 56];
560 let len = tdes.decrypt_into_array(cipher.as_ptr(), cipher.len() as u64, &mut recovered);
561 print!("Ba =\t");
562 for b in recovered.clone()
563 { print!("{:02X} ", b); }
564 println!();
565 let mut txt = String::new();
566 for c in recovered.clone()
567 { write!(txt, "{:02X} ", c); }
568 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E 00 ");
569
570 let mut converted = String::new();
571 unsafe { converted.as_mut_vec() }.write(&recovered);
572 unsafe { converted.as_mut_vec() }.truncate(len as usize);
573 println!("Bb =\t{}", converted);
574 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
575 assert_eq!(converted, message);
576 println!("-------------------------------");
577}
578
579fn bigcryptor64_decrypt_with_padding_iso_ecb_into_string()
580{
581 println!("bigcryptor64_decrypt_with_padding_iso_ecb_into_string()");
582 use std::io::Write;
583 use std::fmt::Write as _;
584 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
585
586 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
588 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
589 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
590 let message = "In the beginning God created the heavens and the earth.";
591 println!("M =\t{}", message);
592 let mut cipher = Vec::<u8>::new();
593 tdes.encrypt_str_into_vec(&message, &mut cipher);
594 print!("C =\t");
595 for c in cipher.clone()
596 { print!("{:02X} ", c); }
597 println!();
598 let mut txt = String::new();
599 for c in cipher.clone()
600 { write!(txt, "{:02X} ", c); }
601 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
602
603 let mut recovered = String::new();
604 tdes.decrypt_into_string(cipher.as_ptr(), cipher.len() as u64, &mut recovered);
605 println!("B =\t{}", recovered);
606 assert_eq!(recovered, "In the beginning God created the heavens and the earth.");
607 assert_eq!(recovered, message);
608 println!("-------------------------------");
609}
610
611fn bigcryptor64_decrypt_vec_with_padding_iso_ecb()
612{
613 println!("bigcryptor64_decrypt_vec_with_padding_iso_ecb()");
614 use std::io::Write;
615 use std::fmt::Write as _;
616 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
617
618 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
620 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
621 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
622 let message = "In the beginning God created the heavens and the earth.";
623 println!("M =\t{}", message);
624 let mut cipher = Vec::<u8>::new();
625 tdes.encrypt_str_into_vec(&message, &mut cipher);
626 print!("C =\t");
627 for c in cipher.clone()
628 { print!("{:02X} ", c); }
629 println!();
630 let mut txt = String::new();
631 for c in cipher.clone()
632 { write!(txt, "{:02X} ", c); }
633 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
634
635 let mut recovered = vec![0; 55];
636 tdes.decrypt_vec(&cipher, recovered.as_mut_ptr());
637 print!("Ba =\t");
638 for b in recovered.clone()
639 { print!("{:02X} ", b); }
640 println!();
641 let mut txt = String::new();
642 for c in recovered.clone()
643 { write!(txt, "{:02X} ", c); }
644 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
645
646 let mut converted = String::new();
647 unsafe { converted.as_mut_vec() }.append(&mut recovered);
648
649 println!("Bb =\t{}", converted);
650 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
651 assert_eq!(converted, message);
652 println!("-------------------------------");
653}
654
655fn bigcryptor64_decrypt_vec_with_padding_iso_ecb_into_vec()
656{
657 println!("bigcryptor64_decrypt_vec_with_padding_iso_ecb_into_vec()");
658 use std::io::Write;
659 use std::fmt::Write as _;
660 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
661
662 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
664 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
665 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
666 let message = "In the beginning God created the heavens and the earth.";
667 println!("M =\t{}", message);
668 let mut cipher = Vec::<u8>::new();
669 tdes.encrypt_str_into_vec(&message, &mut cipher);
670 print!("C =\t");
671 for c in cipher.clone()
672 { print!("{:02X} ", c); }
673 println!();
674 let mut txt = String::new();
675 for c in cipher.clone()
676 { write!(txt, "{:02X} ", c); }
677 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
678
679 let mut recovered = Vec::<u8>::new();
680 tdes.decrypt_vec_into_vec(&cipher, &mut recovered);
681 print!("Ba =\t");
682 for b in recovered.clone()
683 { print!("{:02X} ", b); }
684 println!();
685 let mut txt = String::new();
686 for c in recovered.clone()
687 { write!(txt, "{:02X} ", c); }
688 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
689
690 let mut converted = String::new();
691 unsafe { converted.as_mut_vec() }.append(&mut recovered);
692
693 println!("Bb =\t{}", converted);
694 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
695 assert_eq!(converted, message);
696 println!("-------------------------------");
697}
698
699fn bigcryptor64_decrypt_vec_with_padding_iso_ecb_into_array()
700{
701 println!("bigcryptor64_decrypt_vec_with_padding_iso_ecb_into_array()");
702 use std::io::Write;
703 use std::fmt::Write as _;
704 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
705
706 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
708 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
709 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
710 let message = "In the beginning God created the heavens and the earth.";
711 println!("M =\t{}", message);
712 let mut cipher = Vec::<u8>::new();
713 tdes.encrypt_str_into_vec(&message, &mut cipher);
714 print!("C =\t");
715 for c in cipher.clone()
716 { print!("{:02X} ", c); }
717 println!();
718 let mut txt = String::new();
719 for c in cipher.clone()
720 { write!(txt, "{:02X} ", c); }
721 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
722
723 let mut recovered = [0u8; 56];
724 let len = tdes.decrypt_vec_into_array(&cipher, &mut recovered);
725 print!("Ba =\t");
726 for b in recovered.clone()
727 { print!("{:02X} ", b); }
728 println!();
729 let mut txt = String::new();
730 for c in recovered.clone()
731 { write!(txt, "{:02X} ", c); }
732 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E 00 ");
733
734 let mut converted = String::new();
735 unsafe { converted.as_mut_vec() }.write(&recovered);
736 unsafe { converted.as_mut_vec() }.truncate(len as usize);
737 println!("Bb =\t{}", converted);
738 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
739 assert_eq!(converted, message);
740 println!("-------------------------------");
741}
742
743fn bigcryptor64_decrypt_vec_with_padding_iso_ecb_into_string()
744{
745 println!("bigcryptor64_decrypt_vec_with_padding_iso_ecb_into_string()");
746 use std::io::Write;
747 use std::fmt::Write as _;
748 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
749
750 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
752 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
753 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
754 let message = "In the beginning God created the heavens and the earth.";
755 println!("M =\t{}", message);
756 let mut cipher = Vec::<u8>::new();
757 tdes.encrypt_str_into_vec(&message, &mut cipher);
758 print!("C =\t");
759 for c in cipher.clone()
760 { print!("{:02X} ", c); }
761 println!();
762 let mut txt = String::new();
763 for c in cipher.clone()
764 { write!(txt, "{:02X} ", c); }
765 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
766
767 let mut recovered = String::new();
768 tdes.decrypt_vec_into_string(&cipher, &mut recovered);
769 println!("B =\t{}", recovered);
770 assert_eq!(recovered, "In the beginning God created the heavens and the earth.");
771 assert_eq!(recovered, message);
772 println!("-------------------------------");
773}
774
775fn bigcryptor64_decrypt_array_with_padding_iso_ecb()
776{
777 println!("bigcryptor64_decrypt_array_with_padding_iso_ecb()");
778 use std::io::Write;
779 use std::fmt::Write as _;
780 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
781
782 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
784 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
785 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
786 let message = "In the beginning God created the heavens and the earth.";
787 println!("M =\t{}", message); let mut cipher = [0_u8; 56];
788 tdes.encrypt_str_into_array(&message, &mut cipher);
789 print!("C =\t");
790 for c in cipher.clone()
791 { print!("{:02X} ", c); }
792 println!();
793 let mut txt = String::new();
794 for c in cipher.clone()
795 { write!(txt, "{:02X} ", c); }
796 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
797
798 let mut recovered = vec![0; 55];
799 let len = tdes.decrypt_array(&cipher, recovered.as_mut_ptr());
800 recovered.truncate(len as usize);
801 print!("Ba =\t");
802 for b in recovered.clone()
803 { print!("{:02X} ", b); }
804 println!();
805 let mut txt = String::new();
806 for c in recovered.clone()
807 { write!(txt, "{:02X} ", c); }
808 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
809
810 let mut converted = String::new();
811 unsafe { converted.as_mut_vec() }.append(&mut recovered);
812
813 println!("Bb =\t{}", converted);
814 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
815 assert_eq!(converted, message);
816 println!("-------------------------------");
817}
818
819fn bigcryptor64_decrypt_array_with_padding_iso_ecb_into_vec()
820{
821 println!("bigcryptor64_decrypt_array_with_padding_iso_ecb_into_vec()");
822 use std::io::Write;
823 use std::fmt::Write as _;
824 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
825
826 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
828 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
829 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
830 let message = "In the beginning God created the heavens and the earth.";
831 println!("M =\t{}", message); let mut cipher = [0_u8; 56];
832 tdes.encrypt_str_into_array(&message, &mut cipher);
833 print!("C =\t");
834 for c in cipher.clone()
835 { print!("{:02X} ", c); }
836 println!();
837 let mut txt = String::new();
838 for c in cipher.clone()
839 { write!(txt, "{:02X} ", c); }
840 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
841
842 let mut recovered = Vec::<u8>::new();
843 tdes.decrypt_array_into_vec(&cipher, &mut recovered);
844 print!("Ba =\t");
845 for b in recovered.clone()
846 { print!("{:02X} ", b); }
847 println!();
848 let mut txt = String::new();
849 for c in recovered.clone()
850 { write!(txt, "{:02X} ", c); }
851 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E ");
852
853 let mut converted = String::new();
854 unsafe { converted.as_mut_vec() }.append(&mut recovered);
855
856 println!("Bb =\t{}", converted);
857 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
858 assert_eq!(converted, message);
859 println!("-------------------------------");
860}
861
862fn bigcryptor64_decrypt_array_with_padding_iso_ecb_into_array()
863{
864 println!("bigcryptor64_decrypt_array_with_padding_iso_ecb_into_array()");
865 use std::io::Write;
866 use std::fmt::Write as _;
867 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
868
869 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
871 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
872 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
873 let message = "In the beginning God created the heavens and the earth.";
874 println!("M =\t{}", message); let mut cipher = [0_u8; 56];
875 tdes.encrypt_str_into_array(&message, &mut cipher);
876 print!("C =\t");
877 for c in cipher.clone()
878 { print!("{:02X} ", c); }
879 println!();
880 let mut txt = String::new();
881 for c in cipher.clone()
882 { write!(txt, "{:02X} ", c); }
883 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
884
885 let mut recovered = [0u8; 56];
886 let len = tdes.decrypt_array_into_array(&cipher, &mut recovered);
887 print!("Ba =\t");
888 for b in recovered.clone()
889 { print!("{:02X} ", b); }
890 println!();
891 let mut txt = String::new();
892 for c in recovered.clone()
893 { write!(txt, "{:02X} ", c); }
894 assert_eq!(txt, "49 6E 20 74 68 65 20 62 65 67 69 6E 6E 69 6E 67 20 47 6F 64 20 63 72 65 61 74 65 64 20 74 68 65 20 68 65 61 76 65 6E 73 20 61 6E 64 20 74 68 65 20 65 61 72 74 68 2E 00 ");
895
896 let mut converted = String::new();
897 unsafe { converted.as_mut_vec() }.write(&recovered);
898 unsafe { converted.as_mut_vec() }.truncate(len as usize);
899 println!("Bb =\t{}", converted);
900 assert_eq!(converted, "In the beginning God created the heavens and the earth.");
901 assert_eq!(converted, message);
902 println!("-------------------------------");
903}
904
905fn bigcryptor64_decrypt_array_with_padding_iso_ecb_into_string()
906{
907 println!("bigcryptor64_decrypt_array_with_padding_iso_ecb_into_string()");
908 use std::io::Write;
909 use std::fmt::Write as _;
910 use cryptocol::symmetric::{ BigCryptor64, DES, ECB_ISO };
911
912 let mut tdes = DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64)
914 + DES::decryptor_with_key_u64(0x_FEDCBA0987654321_u64)
915 + DES::encryptor_with_key_u64(0x_1234567890ABCDEF_u64);
916 let message = "In the beginning God created the heavens and the earth.";
917 println!("M =\t{}", message); let mut cipher = [0_u8; 56];
918 tdes.encrypt_str_into_array(&message, &mut cipher);
919 print!("C =\t");
920 for c in cipher.clone()
921 { print!("{:02X} ", c); }
922 println!();
923 let mut txt = String::new();
924 for c in cipher.clone()
925 { write!(txt, "{:02X} ", c); }
926 assert_eq!(txt, "99 2D 87 B2 70 5A 21 3B 7C 93 1A 2E D7 B9 3E E1 FD 47 70 51 48 1F 96 06 2E F3 64 AE 43 11 9C 72 E3 90 65 CF 5B FC 08 12 7A 99 5B B1 2F 7F B4 5D 49 94 44 D4 8B 57 00 30 ");
927
928 let mut recovered = String::new();
929 tdes.decrypt_array_into_string(&cipher, &mut recovered);
930 println!("B =\t{}", recovered);
931 assert_eq!(recovered, "In the beginning God created the heavens and the earth.");
932 assert_eq!(recovered, message);
933 println!("-------------------------------");
934}