comparison dcrypt/misc/checksums/CRC32.d @ 28:ad687db713a4

Further reworked the code for hash padding. Replaced all instances of 'char[]' with 'string' and removed a few 'const' modifiers as per Glenn Haecker's patch for D2 compatibility. Updated CONTRIBUTORS file.
author Thomas Dixon <reikon@reikon.us>
date Sun, 10 May 2009 22:38:48 -0400
parents 176c933827a8
children 21847420b1ac
comparison
equal deleted inserted replaced
27:8b5eaf3c2979 28:ad687db713a4
75 crc = table[cast(ubyte)(crc ^ i)] ^ (crc >> 8); 75 crc = table[cast(ubyte)(crc ^ i)] ^ (crc >> 8);
76 76
77 return (crc ^ 0xffffffff); 77 return (crc ^ 0xffffffff);
78 } 78 }
79 79
80 char[] name() { 80 string name() {
81 return "CRC32"; 81 return "CRC32";
82 } 82 }
83 83
84 debug (UnitTest) { 84 debug (UnitTest) {
85 unittest { 85 unittest {
86 static char[][] test_inputs = [ 86 static string[] test_inputs = [
87 "", 87 "",
88 "a", 88 "a",
89 "checksum", 89 "checksum",
90 "chexksum" 90 "chexksum"
91 ]; 91 ];
96 0xde6fdf9au, 96 0xde6fdf9au,
97 0xc95f7909u 97 0xc95f7909u
98 ]; 98 ];
99 99
100 CRC32 crc32 = new CRC32; 100 CRC32 crc32 = new CRC32;
101 foreach (uint i, char[] j; test_inputs) 101 foreach (uint i, string j; test_inputs)
102 assert(crc32.compute(j) == test_results[i], crc32.name); 102 assert(crc32.compute(j) == test_results[i], crc32.name);
103 } 103 }
104 } 104 }
105 } 105 }