aboutsummaryrefslogtreecommitdiff
path: root/src/unit/md5.unit
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/unit/md5.unit124
1 files changed, 62 insertions, 62 deletions
diff --git a/src/unit/md5.unit b/src/unit/md5.unit
index 248aaaf..aaba113 100644
--- a/src/unit/md5.unit
+++ b/src/unit/md5.unit
@@ -12,71 +12,71 @@
12 12
13suite Md5 13suite Md5
14{ 14{
15 test basics 15 test basics
16 { 16 {
17#define tryStr( a, b ) \ 17#define tryStr( a, b ) \
18 { Bu::Md5 m; m.addData(a); unitTest( m.getHexResult() == b ); } (void)0 18 { Bu::Md5 m; m.addData(a); unitTest( m.getHexResult() == b ); } (void)0
19 tryStr("", "d41d8cd98f00b204e9800998ecf8427e"); 19 tryStr("", "d41d8cd98f00b204e9800998ecf8427e");
20 tryStr("a", "0cc175b9c0f1b6a831c399e269772661"); 20 tryStr("a", "0cc175b9c0f1b6a831c399e269772661");
21 tryStr("abc", "900150983cd24fb0d6963f7d28e17f72"); 21 tryStr("abc", "900150983cd24fb0d6963f7d28e17f72");
22 tryStr("message digest", "f96b697d7cb7938d525a2f31aaf161d0"); 22 tryStr("message digest", "f96b697d7cb7938d525a2f31aaf161d0");
23 tryStr("abcdefghijklmnopqrstuvwxyz", 23 tryStr("abcdefghijklmnopqrstuvwxyz",
24 "c3fcd3d76192e4007dfb496cca67e13b"); 24 "c3fcd3d76192e4007dfb496cca67e13b");
25 tryStr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 25 tryStr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
26 "d174ab98d277d9f5a5611c2c9f419d9f"); 26 "d174ab98d277d9f5a5611c2c9f419d9f");
27 tryStr("12345678901234567890123456789012345" 27 tryStr("12345678901234567890123456789012345"
28 "678901234567890123456789012345678901234567890", 28 "678901234567890123456789012345678901234567890",
29 "57edf4a22be3c955ac49da2e2107b67a"); 29 "57edf4a22be3c955ac49da2e2107b67a");
30 } 30 }
31 31
32 test twoChunks 32 test twoChunks
33 { 33 {
34 Bu::Md5 m; 34 Bu::Md5 m;
35 m.addData("12345678901234567890123456789012345"); 35 m.addData("12345678901234567890123456789012345");
36 m.addData("678901234567890123456789012345678901234567890"); 36 m.addData("678901234567890123456789012345678901234567890");
37 unitTest( m.getHexResult() == "57edf4a22be3c955ac49da2e2107b67a" ); 37 unitTest( m.getHexResult() == "57edf4a22be3c955ac49da2e2107b67a" );
38 } 38 }
39 39
40 test biggerBlocks 40 test biggerBlocks
41 { 41 {
42 const char *sums[33] = { 42 const char *sums[33] = {
43 "75fcf199abe516903321095a588b938d", 43 "75fcf199abe516903321095a588b938d",
44 "e26a863c96d6bdba6601175aedaae108", 44 "e26a863c96d6bdba6601175aedaae108",
45 "2b207fdcb222078d3ebfeb8d5e7c9315", 45 "2b207fdcb222078d3ebfeb8d5e7c9315",
46 "b08683aaa465add72cc2b43ae42f4f70", 46 "b08683aaa465add72cc2b43ae42f4f70",
47 "638bb73963b2d925771c3579ccb5e879", 47 "638bb73963b2d925771c3579ccb5e879",
48 "c727bd4b48a88e3df5924a2604de0790", 48 "c727bd4b48a88e3df5924a2604de0790",
49 "f33d21203c80490f7342e5853c5550eb", 49 "f33d21203c80490f7342e5853c5550eb",
50 "db449faca66a177aae59b1e36a19d053", 50 "db449faca66a177aae59b1e36a19d053",
51 "c800d429afb5f5c820f75c2c94e2e2bb", 51 "c800d429afb5f5c820f75c2c94e2e2bb",
52 "43b79c70b9a6a11e823ffbfa0f45a4db", 52 "43b79c70b9a6a11e823ffbfa0f45a4db",
53 "0177ffc483cf598ae3966b3a5ae00c8c", 53 "0177ffc483cf598ae3966b3a5ae00c8c",
54 "1a68fdf4b17a3820d48d101e9355a818" 54 "1a68fdf4b17a3820d48d101e9355a818"
55 }; 55 };
56 56
57 char block[128]; 57 char block[128];
58 for( int i = 0; i < 128; i++ ) 58 for( int i = 0; i < 128; i++ )
59 block[i] = i*2; 59 block[i] = i*2;
60 60
61 const char **curSum = sums; 61 const char **curSum = sums;
62 for( int j = 1; j < 4096; j*=2 ) 62 for( int j = 1; j < 4096; j*=2 )
63 { 63 {
64 /* 64 /*
65 Bu::File fOut("temp", Bu::File::WriteNew ); 65 Bu::File fOut("temp", Bu::File::WriteNew );
66 for( int b = 0; b < j; b++ ) 66 for( int b = 0; b < j; b++ )
67 { 67 {
68 fOut.write( block, 128 ); 68 fOut.write( block, 128 );
69 } 69 }
70 fOut.close(); 70 fOut.close();
71 system("md5sum -b temp"); 71 system("md5sum -b temp");
72 */ 72 */
73 Bu::Md5 m; 73 Bu::Md5 m;
74 for( int b = 0; b < j; b++ ) 74 for( int b = 0; b < j; b++ )
75 { 75 {
76 m.addData( block, 128 ); 76 m.addData( block, 128 );
77 } 77 }
78 unitTest( m.getHexResult() == *curSum ); 78 unitTest( m.getHexResult() == *curSum );
79 curSum++; 79 curSum++;
80 } 80 }
81 } 81 }
82} 82}