Debian Codegraph @

cmp_cryptgps/blowfish32

raw symbols SCIP
1 #! /bin/sh
2 # (*
3 exec ./top "$0" "$@"
4 *) directory "..";;
5
6 #load "cryptgps.cma";;
7
8 open Crypt_blowfish32;;
9 open Cryptsystem;;
10 open Cryptmodes;;
11 let k = prepare "abcdefghijklmnop";;
12
13 let print s =
14 let l = String.length s in
15 for i = 0 to l/2-1 do
16 let j = 2*i in
17 print_char ' ';
18 print_int ((Char.code(s.[j]) lsl 8 ) lor (Char.code(s.[j+1])))
19 done
20 ;;
21
22
23 let (x3,x2,x1,x0) = encrypt_ecb k (0x3132,0x3334,0x3536,0x3738);;
24 Printf.printf "Result ECB: %d %d %d %d\n" x3 x2 x1 x0;;
25
26 let (v, s) = encrypt_cbc k (0,0,0,0) "12345678abcdefgh";;
27 print_string "Result CBC:";
28 print s;
29 print_newline()
30 ;;
31
32 let (v, s) = encrypt_cfb8 k (0,0,0,0) "12345678abcdefgh";;
33 print_string "Result CFB-8:";
34 print s;
35 print_newline()
36 ;;
37
38 let (v, _, s) = encrypt_cfb64 k (0,0,0,0) 0 "12345678abcdefgh";;
39 print_string "Result CFB-64:";
40 print s;
41 print_newline()
42 ;;
43
44 let (x3,x2,x1,x0) = decrypt_ecb k (0x3132,0x3334,0x3536,0x3738);;
45 Printf.printf "Result de-ECB: %d %d %d %d\n" x3 x2 x1 x0;;
46
47 let (v, s) = decrypt_cbc k (0,0,0,0) "12345678abcdefgh";;
48 print_string "Result de-CBC:";
49 print s;
50 print_newline()
51 ;;
52
53 let (v, s) = decrypt_cfb8 k (0,0,0,0) "12345678abcdefgh";;
54 print_string "Result de-CFB-8:";
55 print s;
56 print_newline()
57 ;;
58
59 let (v, _, s) = decrypt_cfb64 k (0,0,0,0) 0 "12345678abcdefgh";;
60 print_string "Result de-CFB-64:";
61 print s;
62 print_newline()
63 ;;
64
65 let (v, _, s) = crypt_ofb k (0,0,0,0) 0 "12345678abcdefgh";;
66 print_string "Result OFB:";
67 print s;
68 print_newline()
69 ;;