| ... | @@ -1,1463 +1,903 @@ | ... | @@ -1,1463 +1,903 @@ |
| 1 | //! This file is auto-generated by tools/update_crc_catalog.sh. | 1 | //! This file is auto-generated by tools/update_crc_catalog.zig. |
| 2 | | 2 | |
| 3 | const std = @import("../../std.zig"); | 3 | const Crc = @import("../crc.zig").Crc; |
| 4 | const testing = std.testing; | 4 | |
| 5 | const crc = @import("../crc.zig"); | 5 | test { |
| 6 | const Algorithm = crc.Algorithm; | 6 | _ = @import("catalog_test.zig"); |
| 7 | const Crc = crc.Crc; | 7 | } |
| 8 | | 8 | |
| 9 | const crc_3_gsm: Algorithm(u3) = .{ .poly = 0x3, .init = 0x0, .refin = false, .refout = false, .xorout = 0x7, .check = 0x4, .residue = 0x2 }; | 9 | pub const Crc3Gsm = Crc(u3, .{ |
| 10 | | 10 | .polynomial = 0x3, |
| 11 | pub const Crc3Gsm = Crc(u3, crc_3_gsm); | 11 | .initial = 0x0, |
| 12 | | 12 | .reflect_input = false, |
| 13 | test "CRC-3/GSM" { | 13 | .reflect_output = false, |
| 14 | try testing.expectEqual(crc_3_gsm.check, Crc3Gsm.hash("123456789")); | 14 | .xor_output = 0x7, |
| 15 | | 15 | }); |
| 16 | var c = Crc3Gsm.init(); | 16 | |
| 17 | c.update("1234"); | 17 | pub const Crc3Rohc = Crc(u3, .{ |
| 18 | c.update("56789"); | 18 | .polynomial = 0x3, |
| 19 | try testing.expectEqual(crc_3_gsm.check, c.final()); | 19 | .initial = 0x7, |
| 20 | } | 20 | .reflect_input = true, |
| 21 | | 21 | .reflect_output = true, |
| 22 | const crc_3_rohc: Algorithm(u3) = .{ .poly = 0x3, .init = 0x7, .refin = true, .refout = true, .xorout = 0x0, .check = 0x6, .residue = 0x0 }; | 22 | .xor_output = 0x0, |
| 23 | | 23 | }); |
| 24 | pub const Crc3Rohc = Crc(u3, crc_3_rohc); | 24 | |
| 25 | | 25 | pub const Crc4G704 = Crc(u4, .{ |
| 26 | test "CRC-3/ROHC" { | 26 | .polynomial = 0x3, |
| 27 | try testing.expectEqual(crc_3_rohc.check, Crc3Rohc.hash("123456789")); | 27 | .initial = 0x0, |
| 28 | | 28 | .reflect_input = true, |
| 29 | var c = Crc3Rohc.init(); | 29 | .reflect_output = true, |
| 30 | c.update("1234"); | 30 | .xor_output = 0x0, |
| 31 | c.update("56789"); | 31 | }); |
| 32 | try testing.expectEqual(crc_3_rohc.check, c.final()); | 32 | |
| 33 | } | 33 | pub const Crc4Interlaken = Crc(u4, .{ |
| 34 | | 34 | .polynomial = 0x3, |
| 35 | const crc_4_g_704: Algorithm(u4) = .{ .poly = 0x3, .init = 0x0, .refin = true, .refout = true, .xorout = 0x0, .check = 0x7, .residue = 0x0 }; | 35 | .initial = 0xf, |
| 36 | | 36 | .reflect_input = false, |
| 37 | pub const Crc4G704 = Crc(u4, crc_4_g_704); | 37 | .reflect_output = false, |
| 38 | | 38 | .xor_output = 0xf, |
| 39 | test "CRC-4/G-704" { | 39 | }); |
| 40 | try testing.expectEqual(crc_4_g_704.check, Crc4G704.hash("123456789")); | 40 | |
| 41 | | 41 | pub const Crc5EpcC1g2 = Crc(u5, .{ |
| 42 | var c = Crc4G704.init(); | 42 | .polynomial = 0x09, |
| 43 | c.update("1234"); | 43 | .initial = 0x09, |
| 44 | c.update("56789"); | 44 | .reflect_input = false, |
| 45 | try testing.expectEqual(crc_4_g_704.check, c.final()); | 45 | .reflect_output = false, |
| 46 | } | 46 | .xor_output = 0x00, |
| 47 | | 47 | }); |
| 48 | const crc_4_interlaken: Algorithm(u4) = .{ .poly = 0x3, .init = 0xf, .refin = false, .refout = false, .xorout = 0xf, .check = 0xb, .residue = 0x2 }; | 48 | |
| 49 | | 49 | pub const Crc5G704 = Crc(u5, .{ |
| 50 | pub const Crc4Interlaken = Crc(u4, crc_4_interlaken); | 50 | .polynomial = 0x15, |
| 51 | | 51 | .initial = 0x00, |
| 52 | test "CRC-4/INTERLAKEN" { | 52 | .reflect_input = true, |
| 53 | try testing.expectEqual(crc_4_interlaken.check, Crc4Interlaken.hash("123456789")); | 53 | .reflect_output = true, |
| 54 | | 54 | .xor_output = 0x00, |
| 55 | var c = Crc4Interlaken.init(); | 55 | }); |
| 56 | c.update("1234"); | 56 | |
| 57 | c.update("56789"); | 57 | pub const Crc5Usb = Crc(u5, .{ |
| 58 | try testing.expectEqual(crc_4_interlaken.check, c.final()); | 58 | .polynomial = 0x05, |
| 59 | } | 59 | .initial = 0x1f, |
| 60 | | 60 | .reflect_input = true, |
| 61 | const crc_5_epc_c1g2: Algorithm(u5) = .{ .poly = 0x09, .init = 0x09, .refin = false, .refout = false, .xorout = 0x00, .check = 0x00, .residue = 0x00 }; | 61 | .reflect_output = true, |
| 62 | | 62 | .xor_output = 0x1f, |
| 63 | pub const Crc5EpcC1g2 = Crc(u5, crc_5_epc_c1g2); | 63 | }); |
| 64 | | 64 | |
| 65 | test "CRC-5/EPC-C1G2" { | 65 | pub const Crc6Cdma2000A = Crc(u6, .{ |
| 66 | try testing.expectEqual(crc_5_epc_c1g2.check, Crc5EpcC1g2.hash("123456789")); | 66 | .polynomial = 0x27, |
| 67 | | 67 | .initial = 0x3f, |
| 68 | var c = Crc5EpcC1g2.init(); | 68 | .reflect_input = false, |
| 69 | c.update("1234"); | 69 | .reflect_output = false, |
| 70 | c.update("56789"); | 70 | .xor_output = 0x00, |
| 71 | try testing.expectEqual(crc_5_epc_c1g2.check, c.final()); | 71 | }); |
| 72 | } | 72 | |
| 73 | | 73 | pub const Crc6Cdma2000B = Crc(u6, .{ |
| 74 | const crc_5_g_704: Algorithm(u5) = .{ .poly = 0x15, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x07, .residue = 0x00 }; | 74 | .polynomial = 0x07, |
| 75 | | 75 | .initial = 0x3f, |
| 76 | pub const Crc5G704 = Crc(u5, crc_5_g_704); | 76 | .reflect_input = false, |
| 77 | | 77 | .reflect_output = false, |
| 78 | test "CRC-5/G-704" { | 78 | .xor_output = 0x00, |
| 79 | try testing.expectEqual(crc_5_g_704.check, Crc5G704.hash("123456789")); | 79 | }); |
| 80 | | 80 | |
| 81 | var c = Crc5G704.init(); | 81 | pub const Crc6Darc = Crc(u6, .{ |
| 82 | c.update("1234"); | 82 | .polynomial = 0x19, |
| 83 | c.update("56789"); | 83 | .initial = 0x00, |
| 84 | try testing.expectEqual(crc_5_g_704.check, c.final()); | 84 | .reflect_input = true, |
| 85 | } | 85 | .reflect_output = true, |
| 86 | | 86 | .xor_output = 0x00, |
| 87 | const crc_5_usb: Algorithm(u5) = .{ .poly = 0x05, .init = 0x1f, .refin = true, .refout = true, .xorout = 0x1f, .check = 0x19, .residue = 0x06 }; | 87 | }); |
| 88 | | 88 | |
| 89 | pub const Crc5Usb = Crc(u5, crc_5_usb); | 89 | pub const Crc6G704 = Crc(u6, .{ |
| 90 | | 90 | .polynomial = 0x03, |
| 91 | test "CRC-5/USB" { | 91 | .initial = 0x00, |
| 92 | try testing.expectEqual(crc_5_usb.check, Crc5Usb.hash("123456789")); | 92 | .reflect_input = true, |
| 93 | | 93 | .reflect_output = true, |
| 94 | var c = Crc5Usb.init(); | 94 | .xor_output = 0x00, |
| 95 | c.update("1234"); | 95 | }); |
| 96 | c.update("56789"); | 96 | |
| 97 | try testing.expectEqual(crc_5_usb.check, c.final()); | 97 | pub const Crc6Gsm = Crc(u6, .{ |
| 98 | } | 98 | .polynomial = 0x2f, |
| 99 | | 99 | .initial = 0x00, |
| 100 | const crc_6_cdma2000_a: Algorithm(u6) = .{ .poly = 0x27, .init = 0x3f, .refin = false, .refout = false, .xorout = 0x00, .check = 0x0d, .residue = 0x00 }; | 100 | .reflect_input = false, |
| 101 | | 101 | .reflect_output = false, |
| 102 | pub const Crc6Cdma2000A = Crc(u6, crc_6_cdma2000_a); | 102 | .xor_output = 0x3f, |
| 103 | | 103 | }); |
| 104 | test "CRC-6/CDMA2000-A" { | 104 | |
| 105 | try testing.expectEqual(crc_6_cdma2000_a.check, Crc6Cdma2000A.hash("123456789")); | 105 | pub const Crc7Mmc = Crc(u7, .{ |
| 106 | | 106 | .polynomial = 0x09, |
| 107 | var c = Crc6Cdma2000A.init(); | 107 | .initial = 0x00, |
| 108 | c.update("1234"); | 108 | .reflect_input = false, |
| 109 | c.update("56789"); | 109 | .reflect_output = false, |
| 110 | try testing.expectEqual(crc_6_cdma2000_a.check, c.final()); | 110 | .xor_output = 0x00, |
| 111 | } | 111 | }); |
| 112 | | 112 | |
| 113 | const crc_6_cdma2000_b: Algorithm(u6) = .{ .poly = 0x07, .init = 0x3f, .refin = false, .refout = false, .xorout = 0x00, .check = 0x3b, .residue = 0x00 }; | 113 | pub const Crc7Rohc = Crc(u7, .{ |
| 114 | | 114 | .polynomial = 0x4f, |
| 115 | pub const Crc6Cdma2000B = Crc(u6, crc_6_cdma2000_b); | 115 | .initial = 0x7f, |
| 116 | | 116 | .reflect_input = true, |
| 117 | test "CRC-6/CDMA2000-B" { | 117 | .reflect_output = true, |
| 118 | try testing.expectEqual(crc_6_cdma2000_b.check, Crc6Cdma2000B.hash("123456789")); | 118 | .xor_output = 0x00, |
| 119 | | 119 | }); |
| 120 | var c = Crc6Cdma2000B.init(); | 120 | |
| 121 | c.update("1234"); | 121 | pub const Crc7Umts = Crc(u7, .{ |
| 122 | c.update("56789"); | 122 | .polynomial = 0x45, |
| 123 | try testing.expectEqual(crc_6_cdma2000_b.check, c.final()); | 123 | .initial = 0x00, |
| 124 | } | 124 | .reflect_input = false, |
| 125 | | 125 | .reflect_output = false, |
| 126 | const crc_6_darc: Algorithm(u6) = .{ .poly = 0x19, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x26, .residue = 0x00 }; | 126 | .xor_output = 0x00, |
| 127 | | 127 | }); |
| 128 | pub const Crc6Darc = Crc(u6, crc_6_darc); | 128 | |
| 129 | | 129 | pub const Crc8Autosar = Crc(u8, .{ |
| 130 | test "CRC-6/DARC" { | 130 | .polynomial = 0x2f, |
| 131 | try testing.expectEqual(crc_6_darc.check, Crc6Darc.hash("123456789")); | 131 | .initial = 0xff, |
| 132 | | 132 | .reflect_input = false, |
| 133 | var c = Crc6Darc.init(); | 133 | .reflect_output = false, |
| 134 | c.update("1234"); | 134 | .xor_output = 0xff, |
| 135 | c.update("56789"); | 135 | }); |
| 136 | try testing.expectEqual(crc_6_darc.check, c.final()); | 136 | |
| 137 | } | 137 | pub const Crc8Bluetooth = Crc(u8, .{ |
| 138 | | 138 | .polynomial = 0xa7, |
| 139 | const crc_6_g_704: Algorithm(u6) = .{ .poly = 0x03, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x06, .residue = 0x00 }; | 139 | .initial = 0x00, |
| 140 | | 140 | .reflect_input = true, |
| 141 | pub const Crc6G704 = Crc(u6, crc_6_g_704); | 141 | .reflect_output = true, |
| 142 | | 142 | .xor_output = 0x00, |
| 143 | test "CRC-6/G-704" { | 143 | }); |
| 144 | try testing.expectEqual(crc_6_g_704.check, Crc6G704.hash("123456789")); | 144 | |
| 145 | | 145 | pub const Crc8Cdma2000 = Crc(u8, .{ |
| 146 | var c = Crc6G704.init(); | 146 | .polynomial = 0x9b, |
| 147 | c.update("1234"); | 147 | .initial = 0xff, |
| 148 | c.update("56789"); | 148 | .reflect_input = false, |
| 149 | try testing.expectEqual(crc_6_g_704.check, c.final()); | 149 | .reflect_output = false, |
| 150 | } | 150 | .xor_output = 0x00, |
| 151 | | 151 | }); |
| 152 | const crc_6_gsm: Algorithm(u6) = .{ .poly = 0x2f, .init = 0x00, .refin = false, .refout = false, .xorout = 0x3f, .check = 0x13, .residue = 0x3a }; | 152 | |
| 153 | | 153 | pub const Crc8Darc = Crc(u8, .{ |
| 154 | pub const Crc6Gsm = Crc(u6, crc_6_gsm); | 154 | .polynomial = 0x39, |
| 155 | | 155 | .initial = 0x00, |
| 156 | test "CRC-6/GSM" { | 156 | .reflect_input = true, |
| 157 | try testing.expectEqual(crc_6_gsm.check, Crc6Gsm.hash("123456789")); | 157 | .reflect_output = true, |
| 158 | | 158 | .xor_output = 0x00, |
| 159 | var c = Crc6Gsm.init(); | 159 | }); |
| 160 | c.update("1234"); | 160 | |
| 161 | c.update("56789"); | 161 | pub const Crc8DvbS2 = Crc(u8, .{ |
| 162 | try testing.expectEqual(crc_6_gsm.check, c.final()); | 162 | .polynomial = 0xd5, |
| 163 | } | 163 | .initial = 0x00, |
| 164 | | 164 | .reflect_input = false, |
| 165 | const crc_7_mmc: Algorithm(u7) = .{ .poly = 0x09, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0x75, .residue = 0x00 }; | 165 | .reflect_output = false, |
| 166 | | 166 | .xor_output = 0x00, |
| 167 | pub const Crc7Mmc = Crc(u7, crc_7_mmc); | 167 | }); |
| 168 | | 168 | |
| 169 | test "CRC-7/MMC" { | 169 | pub const Crc8GsmA = Crc(u8, .{ |
| 170 | try testing.expectEqual(crc_7_mmc.check, Crc7Mmc.hash("123456789")); | 170 | .polynomial = 0x1d, |
| 171 | | 171 | .initial = 0x00, |
| 172 | var c = Crc7Mmc.init(); | 172 | .reflect_input = false, |
| 173 | c.update("1234"); | 173 | .reflect_output = false, |
| 174 | c.update("56789"); | 174 | .xor_output = 0x00, |
| 175 | try testing.expectEqual(crc_7_mmc.check, c.final()); | 175 | }); |
| 176 | } | 176 | |
| 177 | | 177 | pub const Crc8GsmB = Crc(u8, .{ |
| 178 | const crc_7_rohc: Algorithm(u7) = .{ .poly = 0x4f, .init = 0x7f, .refin = true, .refout = true, .xorout = 0x00, .check = 0x53, .residue = 0x00 }; | 178 | .polynomial = 0x49, |
| 179 | | 179 | .initial = 0x00, |
| 180 | pub const Crc7Rohc = Crc(u7, crc_7_rohc); | 180 | .reflect_input = false, |
| 181 | | 181 | .reflect_output = false, |
| 182 | test "CRC-7/ROHC" { | 182 | .xor_output = 0xff, |
| 183 | try testing.expectEqual(crc_7_rohc.check, Crc7Rohc.hash("123456789")); | 183 | }); |
| 184 | | 184 | |
| 185 | var c = Crc7Rohc.init(); | 185 | pub const Crc8Hitag = Crc(u8, .{ |
| 186 | c.update("1234"); | 186 | .polynomial = 0x1d, |
| 187 | c.update("56789"); | 187 | .initial = 0xff, |
| 188 | try testing.expectEqual(crc_7_rohc.check, c.final()); | 188 | .reflect_input = false, |
| 189 | } | 189 | .reflect_output = false, |
| 190 | | 190 | .xor_output = 0x00, |
| 191 | const crc_7_umts: Algorithm(u7) = .{ .poly = 0x45, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0x61, .residue = 0x00 }; | 191 | }); |
| 192 | | 192 | |
| 193 | pub const Crc7Umts = Crc(u7, crc_7_umts); | 193 | pub const Crc8I4321 = Crc(u8, .{ |
| 194 | | 194 | .polynomial = 0x07, |
| 195 | test "CRC-7/UMTS" { | 195 | .initial = 0x00, |
| 196 | try testing.expectEqual(crc_7_umts.check, Crc7Umts.hash("123456789")); | 196 | .reflect_input = false, |
| 197 | | 197 | .reflect_output = false, |
| 198 | var c = Crc7Umts.init(); | 198 | .xor_output = 0x55, |
| 199 | c.update("1234"); | 199 | }); |
| 200 | c.update("56789"); | 200 | |
| 201 | try testing.expectEqual(crc_7_umts.check, c.final()); | 201 | pub const Crc8ICode = Crc(u8, .{ |
| 202 | } | 202 | .polynomial = 0x1d, |
| 203 | | 203 | .initial = 0xfd, |
| 204 | const crc_8_autosar: Algorithm(u8) = .{ .poly = 0x2f, .init = 0xff, .refin = false, .refout = false, .xorout = 0xff, .check = 0xdf, .residue = 0x42 }; | 204 | .reflect_input = false, |
| 205 | | 205 | .reflect_output = false, |
| 206 | pub const Crc8Autosar = Crc(u8, crc_8_autosar); | 206 | .xor_output = 0x00, |
| 207 | | 207 | }); |
| 208 | test "CRC-8/AUTOSAR" { | 208 | |
| 209 | try testing.expectEqual(crc_8_autosar.check, Crc8Autosar.hash("123456789")); | 209 | pub const Crc8Lte = Crc(u8, .{ |
| 210 | | 210 | .polynomial = 0x9b, |
| 211 | var c = Crc8Autosar.init(); | 211 | .initial = 0x00, |
| 212 | c.update("1234"); | 212 | .reflect_input = false, |
| 213 | c.update("56789"); | 213 | .reflect_output = false, |
| 214 | try testing.expectEqual(crc_8_autosar.check, c.final()); | 214 | .xor_output = 0x00, |
| 215 | } | 215 | }); |
| 216 | | 216 | |
| 217 | const crc_8_bluetooth: Algorithm(u8) = .{ .poly = 0xa7, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x26, .residue = 0x00 }; | 217 | pub const Crc8MaximDow = Crc(u8, .{ |
| 218 | | 218 | .polynomial = 0x31, |
| 219 | pub const Crc8Bluetooth = Crc(u8, crc_8_bluetooth); | 219 | .initial = 0x00, |
| 220 | | 220 | .reflect_input = true, |
| 221 | test "CRC-8/BLUETOOTH" { | 221 | .reflect_output = true, |
| 222 | try testing.expectEqual(crc_8_bluetooth.check, Crc8Bluetooth.hash("123456789")); | 222 | .xor_output = 0x00, |
| 223 | | 223 | }); |
| 224 | var c = Crc8Bluetooth.init(); | 224 | |
| 225 | c.update("1234"); | 225 | pub const Crc8MifareMad = Crc(u8, .{ |
| 226 | c.update("56789"); | 226 | .polynomial = 0x1d, |
| 227 | try testing.expectEqual(crc_8_bluetooth.check, c.final()); | 227 | .initial = 0xc7, |
| 228 | } | 228 | .reflect_input = false, |
| 229 | | 229 | .reflect_output = false, |
| 230 | const crc_8_cdma2000: Algorithm(u8) = .{ .poly = 0x9b, .init = 0xff, .refin = false, .refout = false, .xorout = 0x00, .check = 0xda, .residue = 0x00 }; | 230 | .xor_output = 0x00, |
| 231 | | 231 | }); |
| 232 | pub const Crc8Cdma2000 = Crc(u8, crc_8_cdma2000); | 232 | |
| 233 | | 233 | pub const Crc8Nrsc5 = Crc(u8, .{ |
| 234 | test "CRC-8/CDMA2000" { | 234 | .polynomial = 0x31, |
| 235 | try testing.expectEqual(crc_8_cdma2000.check, Crc8Cdma2000.hash("123456789")); | 235 | .initial = 0xff, |
| 236 | | 236 | .reflect_input = false, |
| 237 | var c = Crc8Cdma2000.init(); | 237 | .reflect_output = false, |
| 238 | c.update("1234"); | 238 | .xor_output = 0x00, |
| 239 | c.update("56789"); | 239 | }); |
| 240 | try testing.expectEqual(crc_8_cdma2000.check, c.final()); | 240 | |
| 241 | } | 241 | pub const Crc8Opensafety = Crc(u8, .{ |
| 242 | | 242 | .polynomial = 0x2f, |
| 243 | const crc_8_darc: Algorithm(u8) = .{ .poly = 0x39, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x15, .residue = 0x00 }; | 243 | .initial = 0x00, |
| 244 | | 244 | .reflect_input = false, |
| 245 | pub const Crc8Darc = Crc(u8, crc_8_darc); | 245 | .reflect_output = false, |
| 246 | | 246 | .xor_output = 0x00, |
| 247 | test "CRC-8/DARC" { | 247 | }); |
| 248 | try testing.expectEqual(crc_8_darc.check, Crc8Darc.hash("123456789")); | 248 | |
| 249 | | 249 | pub const Crc8Rohc = Crc(u8, .{ |
| 250 | var c = Crc8Darc.init(); | 250 | .polynomial = 0x07, |
| 251 | c.update("1234"); | 251 | .initial = 0xff, |
| 252 | c.update("56789"); | 252 | .reflect_input = true, |
| 253 | try testing.expectEqual(crc_8_darc.check, c.final()); | 253 | .reflect_output = true, |
| 254 | } | 254 | .xor_output = 0x00, |
| 255 | | 255 | }); |
| 256 | const crc_8_dvb_s2: Algorithm(u8) = .{ .poly = 0xd5, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0xbc, .residue = 0x00 }; | 256 | |
| 257 | | 257 | pub const Crc8SaeJ1850 = Crc(u8, .{ |
| 258 | pub const Crc8DvbS2 = Crc(u8, crc_8_dvb_s2); | 258 | .polynomial = 0x1d, |
| 259 | | 259 | .initial = 0xff, |
| 260 | test "CRC-8/DVB-S2" { | 260 | .reflect_input = false, |
| 261 | try testing.expectEqual(crc_8_dvb_s2.check, Crc8DvbS2.hash("123456789")); | 261 | .reflect_output = false, |
| 262 | | 262 | .xor_output = 0xff, |
| 263 | var c = Crc8DvbS2.init(); | 263 | }); |
| 264 | c.update("1234"); | 264 | |
| 265 | c.update("56789"); | 265 | pub const Crc8Smbus = Crc(u8, .{ |
| 266 | try testing.expectEqual(crc_8_dvb_s2.check, c.final()); | 266 | .polynomial = 0x07, |
| 267 | } | 267 | .initial = 0x00, |
| 268 | | 268 | .reflect_input = false, |
| 269 | const crc_8_gsm_a: Algorithm(u8) = .{ .poly = 0x1d, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0x37, .residue = 0x00 }; | 269 | .reflect_output = false, |
| 270 | | 270 | .xor_output = 0x00, |
| 271 | pub const Crc8GsmA = Crc(u8, crc_8_gsm_a); | 271 | }); |
| 272 | | 272 | |
| 273 | test "CRC-8/GSM-A" { | 273 | pub const Crc8Tech3250 = Crc(u8, .{ |
| 274 | try testing.expectEqual(crc_8_gsm_a.check, Crc8GsmA.hash("123456789")); | 274 | .polynomial = 0x1d, |
| 275 | | 275 | .initial = 0xff, |
| 276 | var c = Crc8GsmA.init(); | 276 | .reflect_input = true, |
| 277 | c.update("1234"); | 277 | .reflect_output = true, |
| 278 | c.update("56789"); | 278 | .xor_output = 0x00, |
| 279 | try testing.expectEqual(crc_8_gsm_a.check, c.final()); | 279 | }); |
| 280 | } | 280 | |
| 281 | | 281 | pub const Crc8Wcdma = Crc(u8, .{ |
| 282 | const crc_8_gsm_b: Algorithm(u8) = .{ .poly = 0x49, .init = 0x00, .refin = false, .refout = false, .xorout = 0xff, .check = 0x94, .residue = 0x53 }; | 282 | .polynomial = 0x9b, |
| 283 | | 283 | .initial = 0x00, |
| 284 | pub const Crc8GsmB = Crc(u8, crc_8_gsm_b); | 284 | .reflect_input = true, |
| 285 | | 285 | .reflect_output = true, |
| 286 | test "CRC-8/GSM-B" { | 286 | .xor_output = 0x00, |
| 287 | try testing.expectEqual(crc_8_gsm_b.check, Crc8GsmB.hash("123456789")); | 287 | }); |
| 288 | | 288 | |
| 289 | var c = Crc8GsmB.init(); | 289 | pub const Crc10Atm = Crc(u10, .{ |
| 290 | c.update("1234"); | 290 | .polynomial = 0x233, |
| 291 | c.update("56789"); | 291 | .initial = 0x000, |
| 292 | try testing.expectEqual(crc_8_gsm_b.check, c.final()); | 292 | .reflect_input = false, |
| 293 | } | 293 | .reflect_output = false, |
| 294 | | 294 | .xor_output = 0x000, |
| 295 | const crc_8_hitag: Algorithm(u8) = .{ .poly = 0x1d, .init = 0xff, .refin = false, .refout = false, .xorout = 0x00, .check = 0xb4, .residue = 0x00 }; | 295 | }); |
| 296 | | 296 | |
| 297 | pub const Crc8Hitag = Crc(u8, crc_8_hitag); | 297 | pub const Crc10Cdma2000 = Crc(u10, .{ |
| 298 | | 298 | .polynomial = 0x3d9, |
| 299 | test "CRC-8/HITAG" { | 299 | .initial = 0x3ff, |
| 300 | try testing.expectEqual(crc_8_hitag.check, Crc8Hitag.hash("123456789")); | 300 | .reflect_input = false, |
| 301 | | 301 | .reflect_output = false, |
| 302 | var c = Crc8Hitag.init(); | 302 | .xor_output = 0x000, |
| 303 | c.update("1234"); | 303 | }); |
| 304 | c.update("56789"); | 304 | |
| 305 | try testing.expectEqual(crc_8_hitag.check, c.final()); | 305 | pub const Crc10Gsm = Crc(u10, .{ |
| 306 | } | 306 | .polynomial = 0x175, |
| 307 | | 307 | .initial = 0x000, |
| 308 | const crc_8_i_432_1: Algorithm(u8) = .{ .poly = 0x07, .init = 0x00, .refin = false, .refout = false, .xorout = 0x55, .check = 0xa1, .residue = 0xac }; | 308 | .reflect_input = false, |
| 309 | | 309 | .reflect_output = false, |
| 310 | pub const Crc8I4321 = Crc(u8, crc_8_i_432_1); | 310 | .xor_output = 0x3ff, |
| 311 | | 311 | }); |
| 312 | test "CRC-8/I-432-1" { | 312 | |
| 313 | try testing.expectEqual(crc_8_i_432_1.check, Crc8I4321.hash("123456789")); | 313 | pub const Crc11Flexray = Crc(u11, .{ |
| 314 | | 314 | .polynomial = 0x385, |
| 315 | var c = Crc8I4321.init(); | 315 | .initial = 0x01a, |
| 316 | c.update("1234"); | 316 | .reflect_input = false, |
| 317 | c.update("56789"); | 317 | .reflect_output = false, |
| 318 | try testing.expectEqual(crc_8_i_432_1.check, c.final()); | 318 | .xor_output = 0x000, |
| 319 | } | 319 | }); |
| 320 | | 320 | |
| 321 | const crc_8_i_code: Algorithm(u8) = .{ .poly = 0x1d, .init = 0xfd, .refin = false, .refout = false, .xorout = 0x00, .check = 0x7e, .residue = 0x00 }; | 321 | pub const Crc11Umts = Crc(u11, .{ |
| 322 | | 322 | .polynomial = 0x307, |
| 323 | pub const Crc8ICode = Crc(u8, crc_8_i_code); | 323 | .initial = 0x000, |
| 324 | | 324 | .reflect_input = false, |
| 325 | test "CRC-8/I-CODE" { | 325 | .reflect_output = false, |
| 326 | try testing.expectEqual(crc_8_i_code.check, Crc8ICode.hash("123456789")); | 326 | .xor_output = 0x000, |
| 327 | | 327 | }); |
| 328 | var c = Crc8ICode.init(); | 328 | |
| 329 | c.update("1234"); | 329 | pub const Crc12Cdma2000 = Crc(u12, .{ |
| 330 | c.update("56789"); | 330 | .polynomial = 0xf13, |
| 331 | try testing.expectEqual(crc_8_i_code.check, c.final()); | 331 | .initial = 0xfff, |
| 332 | } | 332 | .reflect_input = false, |
| 333 | | 333 | .reflect_output = false, |
| 334 | const crc_8_lte: Algorithm(u8) = .{ .poly = 0x9b, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0xea, .residue = 0x00 }; | 334 | .xor_output = 0x000, |
| 335 | | 335 | }); |
| 336 | pub const Crc8Lte = Crc(u8, crc_8_lte); | 336 | |
| 337 | | 337 | pub const Crc12Dect = Crc(u12, .{ |
| 338 | test "CRC-8/LTE" { | 338 | .polynomial = 0x80f, |
| 339 | try testing.expectEqual(crc_8_lte.check, Crc8Lte.hash("123456789")); | 339 | .initial = 0x000, |
| 340 | | 340 | .reflect_input = false, |
| 341 | var c = Crc8Lte.init(); | 341 | .reflect_output = false, |
| 342 | c.update("1234"); | 342 | .xor_output = 0x000, |
| 343 | c.update("56789"); | 343 | }); |
| 344 | try testing.expectEqual(crc_8_lte.check, c.final()); | 344 | |
| 345 | } | 345 | pub const Crc12Gsm = Crc(u12, .{ |
| 346 | | 346 | .polynomial = 0xd31, |
| 347 | const crc_8_maxim_dow: Algorithm(u8) = .{ .poly = 0x31, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0xa1, .residue = 0x00 }; | 347 | .initial = 0x000, |
| 348 | | 348 | .reflect_input = false, |
| 349 | pub const Crc8MaximDow = Crc(u8, crc_8_maxim_dow); | 349 | .reflect_output = false, |
| 350 | | 350 | .xor_output = 0xfff, |
| 351 | test "CRC-8/MAXIM-DOW" { | 351 | }); |
| 352 | try testing.expectEqual(crc_8_maxim_dow.check, Crc8MaximDow.hash("123456789")); | 352 | |
| 353 | | 353 | pub const Crc12Umts = Crc(u12, .{ |
| 354 | var c = Crc8MaximDow.init(); | 354 | .polynomial = 0x80f, |
| 355 | c.update("1234"); | 355 | .initial = 0x000, |
| 356 | c.update("56789"); | 356 | .reflect_input = false, |
| 357 | try testing.expectEqual(crc_8_maxim_dow.check, c.final()); | 357 | .reflect_output = true, |
| 358 | } | 358 | .xor_output = 0x000, |
| 359 | | 359 | }); |
| 360 | const crc_8_mifare_mad: Algorithm(u8) = .{ .poly = 0x1d, .init = 0xc7, .refin = false, .refout = false, .xorout = 0x00, .check = 0x99, .residue = 0x00 }; | 360 | |
| 361 | | 361 | pub const Crc13Bbc = Crc(u13, .{ |
| 362 | pub const Crc8MifareMad = Crc(u8, crc_8_mifare_mad); | 362 | .polynomial = 0x1cf5, |
| 363 | | 363 | .initial = 0x0000, |
| 364 | test "CRC-8/MIFARE-MAD" { | 364 | .reflect_input = false, |
| 365 | try testing.expectEqual(crc_8_mifare_mad.check, Crc8MifareMad.hash("123456789")); | 365 | .reflect_output = false, |
| 366 | | 366 | .xor_output = 0x0000, |
| 367 | var c = Crc8MifareMad.init(); | 367 | }); |
| 368 | c.update("1234"); | 368 | |
| 369 | c.update("56789"); | 369 | pub const Crc14Darc = Crc(u14, .{ |
| 370 | try testing.expectEqual(crc_8_mifare_mad.check, c.final()); | 370 | .polynomial = 0x0805, |
| 371 | } | 371 | .initial = 0x0000, |
| 372 | | 372 | .reflect_input = true, |
| 373 | const crc_8_nrsc_5: Algorithm(u8) = .{ .poly = 0x31, .init = 0xff, .refin = false, .refout = false, .xorout = 0x00, .check = 0xf7, .residue = 0x00 }; | 373 | .reflect_output = true, |
| 374 | | 374 | .xor_output = 0x0000, |
| 375 | pub const Crc8Nrsc5 = Crc(u8, crc_8_nrsc_5); | 375 | }); |
| 376 | | 376 | |
| 377 | test "CRC-8/NRSC-5" { | 377 | pub const Crc14Gsm = Crc(u14, .{ |
| 378 | try testing.expectEqual(crc_8_nrsc_5.check, Crc8Nrsc5.hash("123456789")); | 378 | .polynomial = 0x202d, |
| 379 | | 379 | .initial = 0x0000, |
| 380 | var c = Crc8Nrsc5.init(); | 380 | .reflect_input = false, |
| 381 | c.update("1234"); | 381 | .reflect_output = false, |
| 382 | c.update("56789"); | 382 | .xor_output = 0x3fff, |
| 383 | try testing.expectEqual(crc_8_nrsc_5.check, c.final()); | 383 | }); |
| 384 | } | 384 | |
| 385 | | 385 | pub const Crc15Can = Crc(u15, .{ |
| 386 | const crc_8_opensafety: Algorithm(u8) = .{ .poly = 0x2f, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0x3e, .residue = 0x00 }; | 386 | .polynomial = 0x4599, |
| 387 | | 387 | .initial = 0x0000, |
| 388 | pub const Crc8Opensafety = Crc(u8, crc_8_opensafety); | 388 | .reflect_input = false, |
| 389 | | 389 | .reflect_output = false, |
| 390 | test "CRC-8/OPENSAFETY" { | 390 | .xor_output = 0x0000, |
| 391 | try testing.expectEqual(crc_8_opensafety.check, Crc8Opensafety.hash("123456789")); | 391 | }); |
| 392 | | 392 | |
| 393 | var c = Crc8Opensafety.init(); | 393 | pub const Crc15Mpt1327 = Crc(u15, .{ |
| 394 | c.update("1234"); | 394 | .polynomial = 0x6815, |
| 395 | c.update("56789"); | 395 | .initial = 0x0000, |
| 396 | try testing.expectEqual(crc_8_opensafety.check, c.final()); | 396 | .reflect_input = false, |
| 397 | } | 397 | .reflect_output = false, |
| 398 | | 398 | .xor_output = 0x0001, |
| 399 | const crc_8_rohc: Algorithm(u8) = .{ .poly = 0x07, .init = 0xff, .refin = true, .refout = true, .xorout = 0x00, .check = 0xd0, .residue = 0x00 }; | 399 | }); |
| 400 | | 400 | |
| 401 | pub const Crc8Rohc = Crc(u8, crc_8_rohc); | 401 | pub const Crc16Arc = Crc(u16, .{ |
| 402 | | 402 | .polynomial = 0x8005, |
| 403 | test "CRC-8/ROHC" { | 403 | .initial = 0x0000, |
| 404 | try testing.expectEqual(crc_8_rohc.check, Crc8Rohc.hash("123456789")); | 404 | .reflect_input = true, |
| 405 | | 405 | .reflect_output = true, |
| 406 | var c = Crc8Rohc.init(); | 406 | .xor_output = 0x0000, |
| 407 | c.update("1234"); | 407 | }); |
| 408 | c.update("56789"); | 408 | |
| 409 | try testing.expectEqual(crc_8_rohc.check, c.final()); | 409 | pub const Crc16Cdma2000 = Crc(u16, .{ |
| 410 | } | 410 | .polynomial = 0xc867, |
| 411 | | 411 | .initial = 0xffff, |
| 412 | const crc_8_sae_j1850: Algorithm(u8) = .{ .poly = 0x1d, .init = 0xff, .refin = false, .refout = false, .xorout = 0xff, .check = 0x4b, .residue = 0xc4 }; | 412 | .reflect_input = false, |
| 413 | | 413 | .reflect_output = false, |
| 414 | pub const Crc8SaeJ1850 = Crc(u8, crc_8_sae_j1850); | 414 | .xor_output = 0x0000, |
| 415 | | 415 | }); |
| 416 | test "CRC-8/SAE-J1850" { | 416 | |
| 417 | try testing.expectEqual(crc_8_sae_j1850.check, Crc8SaeJ1850.hash("123456789")); | 417 | pub const Crc16Cms = Crc(u16, .{ |
| 418 | | 418 | .polynomial = 0x8005, |
| 419 | var c = Crc8SaeJ1850.init(); | 419 | .initial = 0xffff, |
| 420 | c.update("1234"); | 420 | .reflect_input = false, |
| 421 | c.update("56789"); | 421 | .reflect_output = false, |
| 422 | try testing.expectEqual(crc_8_sae_j1850.check, c.final()); | 422 | .xor_output = 0x0000, |
| 423 | } | 423 | }); |
| 424 | | 424 | |
| 425 | const crc_8_smbus: Algorithm(u8) = .{ .poly = 0x07, .init = 0x00, .refin = false, .refout = false, .xorout = 0x00, .check = 0xf4, .residue = 0x00 }; | 425 | pub const Crc16Dds110 = Crc(u16, .{ |
| 426 | | 426 | .polynomial = 0x8005, |
| 427 | pub const Crc8Smbus = Crc(u8, crc_8_smbus); | 427 | .initial = 0x800d, |
| 428 | | 428 | .reflect_input = false, |
| 429 | test "CRC-8/SMBUS" { | 429 | .reflect_output = false, |
| 430 | try testing.expectEqual(crc_8_smbus.check, Crc8Smbus.hash("123456789")); | 430 | .xor_output = 0x0000, |
| 431 | | 431 | }); |
| 432 | var c = Crc8Smbus.init(); | 432 | |
| 433 | c.update("1234"); | 433 | pub const Crc16DectR = Crc(u16, .{ |
| 434 | c.update("56789"); | 434 | .polynomial = 0x0589, |
| 435 | try testing.expectEqual(crc_8_smbus.check, c.final()); | 435 | .initial = 0x0000, |
| 436 | } | 436 | .reflect_input = false, |
| 437 | | 437 | .reflect_output = false, |
| 438 | const crc_8_tech_3250: Algorithm(u8) = .{ .poly = 0x1d, .init = 0xff, .refin = true, .refout = true, .xorout = 0x00, .check = 0x97, .residue = 0x00 }; | 438 | .xor_output = 0x0001, |
| 439 | | 439 | }); |
| 440 | pub const Crc8Tech3250 = Crc(u8, crc_8_tech_3250); | 440 | |
| 441 | | 441 | pub const Crc16DectX = Crc(u16, .{ |
| 442 | test "CRC-8/TECH-3250" { | 442 | .polynomial = 0x0589, |
| 443 | try testing.expectEqual(crc_8_tech_3250.check, Crc8Tech3250.hash("123456789")); | 443 | .initial = 0x0000, |
| 444 | | 444 | .reflect_input = false, |
| 445 | var c = Crc8Tech3250.init(); | 445 | .reflect_output = false, |
| 446 | c.update("1234"); | 446 | .xor_output = 0x0000, |
| 447 | c.update("56789"); | 447 | }); |
| 448 | try testing.expectEqual(crc_8_tech_3250.check, c.final()); | 448 | |
| 449 | } | 449 | pub const Crc16Dnp = Crc(u16, .{ |
| 450 | | 450 | .polynomial = 0x3d65, |
| 451 | const crc_8_wcdma: Algorithm(u8) = .{ .poly = 0x9b, .init = 0x00, .refin = true, .refout = true, .xorout = 0x00, .check = 0x25, .residue = 0x00 }; | 451 | .initial = 0x0000, |
| 452 | | 452 | .reflect_input = true, |
| 453 | pub const Crc8Wcdma = Crc(u8, crc_8_wcdma); | 453 | .reflect_output = true, |
| 454 | | 454 | .xor_output = 0xffff, |
| 455 | test "CRC-8/WCDMA" { | 455 | }); |
| 456 | try testing.expectEqual(crc_8_wcdma.check, Crc8Wcdma.hash("123456789")); | 456 | |
| 457 | | 457 | pub const Crc16En13757 = Crc(u16, .{ |
| 458 | var c = Crc8Wcdma.init(); | 458 | .polynomial = 0x3d65, |
| 459 | c.update("1234"); | 459 | .initial = 0x0000, |
| 460 | c.update("56789"); | 460 | .reflect_input = false, |
| 461 | try testing.expectEqual(crc_8_wcdma.check, c.final()); | 461 | .reflect_output = false, |
| 462 | } | 462 | .xor_output = 0xffff, |
| 463 | | 463 | }); |
| 464 | const crc_10_atm: Algorithm(u10) = .{ .poly = 0x233, .init = 0x000, .refin = false, .refout = false, .xorout = 0x000, .check = 0x199, .residue = 0x000 }; | 464 | |
| 465 | | 465 | pub const Crc16Genibus = Crc(u16, .{ |
| 466 | pub const Crc10Atm = Crc(u10, crc_10_atm); | 466 | .polynomial = 0x1021, |
| 467 | | 467 | .initial = 0xffff, |
| 468 | test "CRC-10/ATM" { | 468 | .reflect_input = false, |
| 469 | try testing.expectEqual(crc_10_atm.check, Crc10Atm.hash("123456789")); | 469 | .reflect_output = false, |
| 470 | | 470 | .xor_output = 0xffff, |
| 471 | var c = Crc10Atm.init(); | 471 | }); |
| 472 | c.update("1234"); | 472 | |
| 473 | c.update("56789"); | 473 | pub const Crc16Gsm = Crc(u16, .{ |
| 474 | try testing.expectEqual(crc_10_atm.check, c.final()); | 474 | .polynomial = 0x1021, |
| 475 | } | 475 | .initial = 0x0000, |
| 476 | | 476 | .reflect_input = false, |
| 477 | const crc_10_cdma2000: Algorithm(u10) = .{ .poly = 0x3d9, .init = 0x3ff, .refin = false, .refout = false, .xorout = 0x000, .check = 0x233, .residue = 0x000 }; | 477 | .reflect_output = false, |
| 478 | | 478 | .xor_output = 0xffff, |
| 479 | pub const Crc10Cdma2000 = Crc(u10, crc_10_cdma2000); | 479 | }); |
| 480 | | 480 | |
| 481 | test "CRC-10/CDMA2000" { | 481 | pub const Crc16Ibm3740 = Crc(u16, .{ |
| 482 | try testing.expectEqual(crc_10_cdma2000.check, Crc10Cdma2000.hash("123456789")); | 482 | .polynomial = 0x1021, |
| 483 | | 483 | .initial = 0xffff, |
| 484 | var c = Crc10Cdma2000.init(); | 484 | .reflect_input = false, |
| 485 | c.update("1234"); | 485 | .reflect_output = false, |
| 486 | c.update("56789"); | 486 | .xor_output = 0x0000, |
| 487 | try testing.expectEqual(crc_10_cdma2000.check, c.final()); | 487 | }); |
| 488 | } | 488 | |
| 489 | | 489 | pub const Crc16IbmSdlc = Crc(u16, .{ |
| 490 | const crc_10_gsm: Algorithm(u10) = .{ .poly = 0x175, .init = 0x000, .refin = false, .refout = false, .xorout = 0x3ff, .check = 0x12a, .residue = 0x0c6 }; | 490 | .polynomial = 0x1021, |
| 491 | | 491 | .initial = 0xffff, |
| 492 | pub const Crc10Gsm = Crc(u10, crc_10_gsm); | 492 | .reflect_input = true, |
| 493 | | 493 | .reflect_output = true, |
| 494 | test "CRC-10/GSM" { | 494 | .xor_output = 0xffff, |
| 495 | try testing.expectEqual(crc_10_gsm.check, Crc10Gsm.hash("123456789")); | 495 | }); |
| 496 | | 496 | |
| 497 | var c = Crc10Gsm.init(); | 497 | pub const Crc16IsoIec144433A = Crc(u16, .{ |
| 498 | c.update("1234"); | 498 | .polynomial = 0x1021, |
| 499 | c.update("56789"); | 499 | .initial = 0xc6c6, |
| 500 | try testing.expectEqual(crc_10_gsm.check, c.final()); | 500 | .reflect_input = true, |
| 501 | } | 501 | .reflect_output = true, |
| 502 | | 502 | .xor_output = 0x0000, |
| 503 | const crc_11_flexray: Algorithm(u11) = .{ .poly = 0x385, .init = 0x01a, .refin = false, .refout = false, .xorout = 0x000, .check = 0x5a3, .residue = 0x000 }; | 503 | }); |
| 504 | | 504 | |
| 505 | pub const Crc11Flexray = Crc(u11, crc_11_flexray); | 505 | pub const Crc16Kermit = Crc(u16, .{ |
| 506 | | 506 | .polynomial = 0x1021, |
| 507 | test "CRC-11/FLEXRAY" { | 507 | .initial = 0x0000, |
| 508 | try testing.expectEqual(crc_11_flexray.check, Crc11Flexray.hash("123456789")); | 508 | .reflect_input = true, |
| 509 | | 509 | .reflect_output = true, |
| 510 | var c = Crc11Flexray.init(); | 510 | .xor_output = 0x0000, |
| 511 | c.update("1234"); | 511 | }); |
| 512 | c.update("56789"); | 512 | |
| 513 | try testing.expectEqual(crc_11_flexray.check, c.final()); | 513 | pub const Crc16Lj1200 = Crc(u16, .{ |
| 514 | } | 514 | .polynomial = 0x6f63, |
| 515 | | 515 | .initial = 0x0000, |
| 516 | const crc_11_umts: Algorithm(u11) = .{ .poly = 0x307, .init = 0x000, .refin = false, .refout = false, .xorout = 0x000, .check = 0x061, .residue = 0x000 }; | 516 | .reflect_input = false, |
| 517 | | 517 | .reflect_output = false, |
| 518 | pub const Crc11Umts = Crc(u11, crc_11_umts); | 518 | .xor_output = 0x0000, |
| 519 | | 519 | }); |
| 520 | test "CRC-11/UMTS" { | 520 | |
| 521 | try testing.expectEqual(crc_11_umts.check, Crc11Umts.hash("123456789")); | 521 | pub const Crc16M17 = Crc(u16, .{ |
| 522 | | 522 | .polynomial = 0x5935, |
| 523 | var c = Crc11Umts.init(); | 523 | .initial = 0xffff, |
| 524 | c.update("1234"); | 524 | .reflect_input = false, |
| 525 | c.update("56789"); | 525 | .reflect_output = false, |
| 526 | try testing.expectEqual(crc_11_umts.check, c.final()); | 526 | .xor_output = 0x0000, |
| 527 | } | 527 | }); |
| 528 | | 528 | |
| 529 | const crc_12_cdma2000: Algorithm(u12) = .{ .poly = 0xf13, .init = 0xfff, .refin = false, .refout = false, .xorout = 0x000, .check = 0xd4d, .residue = 0x000 }; | 529 | pub const Crc16MaximDow = Crc(u16, .{ |
| 530 | | 530 | .polynomial = 0x8005, |
| 531 | pub const Crc12Cdma2000 = Crc(u12, crc_12_cdma2000); | 531 | .initial = 0x0000, |
| 532 | | 532 | .reflect_input = true, |
| 533 | test "CRC-12/CDMA2000" { | 533 | .reflect_output = true, |
| 534 | try testing.expectEqual(crc_12_cdma2000.check, Crc12Cdma2000.hash("123456789")); | 534 | .xor_output = 0xffff, |
| 535 | | 535 | }); |
| 536 | var c = Crc12Cdma2000.init(); | 536 | |
| 537 | c.update("1234"); | 537 | pub const Crc16Mcrf4xx = Crc(u16, .{ |
| 538 | c.update("56789"); | 538 | .polynomial = 0x1021, |
| 539 | try testing.expectEqual(crc_12_cdma2000.check, c.final()); | 539 | .initial = 0xffff, |
| 540 | } | 540 | .reflect_input = true, |
| 541 | | 541 | .reflect_output = true, |
| 542 | const crc_12_dect: Algorithm(u12) = .{ .poly = 0x80f, .init = 0x000, .refin = false, .refout = false, .xorout = 0x000, .check = 0xf5b, .residue = 0x000 }; | 542 | .xor_output = 0x0000, |
| 543 | | 543 | }); |
| 544 | pub const Crc12Dect = Crc(u12, crc_12_dect); | 544 | |
| 545 | | 545 | pub const Crc16Modbus = Crc(u16, .{ |
| 546 | test "CRC-12/DECT" { | 546 | .polynomial = 0x8005, |
| 547 | try testing.expectEqual(crc_12_dect.check, Crc12Dect.hash("123456789")); | 547 | .initial = 0xffff, |
| 548 | | 548 | .reflect_input = true, |
| 549 | var c = Crc12Dect.init(); | 549 | .reflect_output = true, |
| 550 | c.update("1234"); | 550 | .xor_output = 0x0000, |
| 551 | c.update("56789"); | 551 | }); |
| 552 | try testing.expectEqual(crc_12_dect.check, c.final()); | 552 | |
| 553 | } | 553 | pub const Crc16Nrsc5 = Crc(u16, .{ |
| 554 | | 554 | .polynomial = 0x080b, |
| 555 | const crc_12_gsm: Algorithm(u12) = .{ .poly = 0xd31, .init = 0x000, .refin = false, .refout = false, .xorout = 0xfff, .check = 0xb34, .residue = 0x178 }; | 555 | .initial = 0xffff, |
| 556 | | 556 | .reflect_input = true, |
| 557 | pub const Crc12Gsm = Crc(u12, crc_12_gsm); | 557 | .reflect_output = true, |
| 558 | | 558 | .xor_output = 0x0000, |
| 559 | test "CRC-12/GSM" { | 559 | }); |
| 560 | try testing.expectEqual(crc_12_gsm.check, Crc12Gsm.hash("123456789")); | 560 | |
| 561 | | 561 | pub const Crc16OpensafetyA = Crc(u16, .{ |
| 562 | var c = Crc12Gsm.init(); | 562 | .polynomial = 0x5935, |
| 563 | c.update("1234"); | 563 | .initial = 0x0000, |
| 564 | c.update("56789"); | 564 | .reflect_input = false, |
| 565 | try testing.expectEqual(crc_12_gsm.check, c.final()); | 565 | .reflect_output = false, |
| 566 | } | 566 | .xor_output = 0x0000, |
| 567 | | 567 | }); |
| 568 | const crc_12_umts: Algorithm(u12) = .{ .poly = 0x80f, .init = 0x000, .refin = false, .refout = true, .xorout = 0x000, .check = 0xdaf, .residue = 0x000 }; | 568 | |
| 569 | | 569 | pub const Crc16OpensafetyB = Crc(u16, .{ |
| 570 | pub const Crc12Umts = Crc(u12, crc_12_umts); | 570 | .polynomial = 0x755b, |
| 571 | | 571 | .initial = 0x0000, |
| 572 | test "CRC-12/UMTS" { | 572 | .reflect_input = false, |
| 573 | try testing.expectEqual(crc_12_umts.check, Crc12Umts.hash("123456789")); | 573 | .reflect_output = false, |
| 574 | | 574 | .xor_output = 0x0000, |
| 575 | var c = Crc12Umts.init(); | 575 | }); |
| 576 | c.update("1234"); | 576 | |
| 577 | c.update("56789"); | 577 | pub const Crc16Profibus = Crc(u16, .{ |
| 578 | try testing.expectEqual(crc_12_umts.check, c.final()); | 578 | .polynomial = 0x1dcf, |
| 579 | } | 579 | .initial = 0xffff, |
| 580 | | 580 | .reflect_input = false, |
| 581 | const crc_13_bbc: Algorithm(u13) = .{ .poly = 0x1cf5, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x04fa, .residue = 0x0000 }; | 581 | .reflect_output = false, |
| 582 | | 582 | .xor_output = 0xffff, |
| 583 | pub const Crc13Bbc = Crc(u13, crc_13_bbc); | 583 | }); |
| 584 | | 584 | |
| 585 | test "CRC-13/BBC" { | 585 | pub const Crc16Riello = Crc(u16, .{ |
| 586 | try testing.expectEqual(crc_13_bbc.check, Crc13Bbc.hash("123456789")); | 586 | .polynomial = 0x1021, |
| 587 | | 587 | .initial = 0xb2aa, |
| 588 | var c = Crc13Bbc.init(); | 588 | .reflect_input = true, |
| 589 | c.update("1234"); | 589 | .reflect_output = true, |
| 590 | c.update("56789"); | 590 | .xor_output = 0x0000, |
| 591 | try testing.expectEqual(crc_13_bbc.check, c.final()); | 591 | }); |
| 592 | } | 592 | |
| 593 | | 593 | pub const Crc16SpiFujitsu = Crc(u16, .{ |
| 594 | const crc_14_darc: Algorithm(u14) = .{ .poly = 0x0805, .init = 0x0000, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x082d, .residue = 0x0000 }; | 594 | .polynomial = 0x1021, |
| 595 | | 595 | .initial = 0x1d0f, |
| 596 | pub const Crc14Darc = Crc(u14, crc_14_darc); | 596 | .reflect_input = false, |
| 597 | | 597 | .reflect_output = false, |
| 598 | test "CRC-14/DARC" { | 598 | .xor_output = 0x0000, |
| 599 | try testing.expectEqual(crc_14_darc.check, Crc14Darc.hash("123456789")); | 599 | }); |
| 600 | | 600 | |
| 601 | var c = Crc14Darc.init(); | 601 | pub const Crc16T10Dif = Crc(u16, .{ |
| 602 | c.update("1234"); | 602 | .polynomial = 0x8bb7, |
| 603 | c.update("56789"); | 603 | .initial = 0x0000, |
| 604 | try testing.expectEqual(crc_14_darc.check, c.final()); | 604 | .reflect_input = false, |
| 605 | } | 605 | .reflect_output = false, |
| 606 | | 606 | .xor_output = 0x0000, |
| 607 | const crc_14_gsm: Algorithm(u14) = .{ .poly = 0x202d, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x3fff, .check = 0x30ae, .residue = 0x031e }; | 607 | }); |
| 608 | | 608 | |
| 609 | pub const Crc14Gsm = Crc(u14, crc_14_gsm); | 609 | pub const Crc16Teledisk = Crc(u16, .{ |
| 610 | | 610 | .polynomial = 0xa097, |
| 611 | test "CRC-14/GSM" { | 611 | .initial = 0x0000, |
| 612 | try testing.expectEqual(crc_14_gsm.check, Crc14Gsm.hash("123456789")); | 612 | .reflect_input = false, |
| 613 | | 613 | .reflect_output = false, |
| 614 | var c = Crc14Gsm.init(); | 614 | .xor_output = 0x0000, |
| 615 | c.update("1234"); | 615 | }); |
| 616 | c.update("56789"); | 616 | |
| 617 | try testing.expectEqual(crc_14_gsm.check, c.final()); | 617 | pub const Crc16Tms37157 = Crc(u16, .{ |
| 618 | } | 618 | .polynomial = 0x1021, |
| 619 | | 619 | .initial = 0x89ec, |
| 620 | const crc_15_can: Algorithm(u15) = .{ .poly = 0x4599, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x059e, .residue = 0x0000 }; | 620 | .reflect_input = true, |
| 621 | | 621 | .reflect_output = true, |
| 622 | pub const Crc15Can = Crc(u15, crc_15_can); | 622 | .xor_output = 0x0000, |
| 623 | | 623 | }); |
| 624 | test "CRC-15/CAN" { | 624 | |
| 625 | try testing.expectEqual(crc_15_can.check, Crc15Can.hash("123456789")); | 625 | pub const Crc16Umts = Crc(u16, .{ |
| 626 | | 626 | .polynomial = 0x8005, |
| 627 | var c = Crc15Can.init(); | 627 | .initial = 0x0000, |
| 628 | c.update("1234"); | 628 | .reflect_input = false, |
| 629 | c.update("56789"); | 629 | .reflect_output = false, |
| 630 | try testing.expectEqual(crc_15_can.check, c.final()); | 630 | .xor_output = 0x0000, |
| 631 | } | 631 | }); |
| 632 | | 632 | |
| 633 | const crc_15_mpt1327: Algorithm(u15) = .{ .poly = 0x6815, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0001, .check = 0x2566, .residue = 0x6815 }; | 633 | pub const Crc16Usb = Crc(u16, .{ |
| 634 | | 634 | .polynomial = 0x8005, |
| 635 | pub const Crc15Mpt1327 = Crc(u15, crc_15_mpt1327); | 635 | .initial = 0xffff, |
| 636 | | 636 | .reflect_input = true, |
| 637 | test "CRC-15/MPT1327" { | 637 | .reflect_output = true, |
| 638 | try testing.expectEqual(crc_15_mpt1327.check, Crc15Mpt1327.hash("123456789")); | 638 | .xor_output = 0xffff, |
| 639 | | 639 | }); |
| 640 | var c = Crc15Mpt1327.init(); | 640 | |
| 641 | c.update("1234"); | 641 | pub const Crc16Xmodem = Crc(u16, .{ |
| 642 | c.update("56789"); | 642 | .polynomial = 0x1021, |
| 643 | try testing.expectEqual(crc_15_mpt1327.check, c.final()); | 643 | .initial = 0x0000, |
| 644 | } | 644 | .reflect_input = false, |
| 645 | | 645 | .reflect_output = false, |
| 646 | const crc_16_arc: Algorithm(u16) = .{ .poly = 0x8005, .init = 0x0000, .refin = true, .refout = true, .xorout = 0x0000, .check = 0xbb3d, .residue = 0x0000 }; | 646 | .xor_output = 0x0000, |
| 647 | | 647 | }); |
| 648 | pub const Crc16Arc = Crc(u16, crc_16_arc); | 648 | |
| 649 | | 649 | pub const Crc17CanFd = Crc(u17, .{ |
| 650 | test "CRC-16/ARC" { | 650 | .polynomial = 0x1685b, |
| 651 | try testing.expectEqual(crc_16_arc.check, Crc16Arc.hash("123456789")); | 651 | .initial = 0x00000, |
| 652 | | 652 | .reflect_input = false, |
| 653 | var c = Crc16Arc.init(); | 653 | .reflect_output = false, |
| 654 | c.update("1234"); | 654 | .xor_output = 0x00000, |
| 655 | c.update("56789"); | 655 | }); |
| 656 | try testing.expectEqual(crc_16_arc.check, c.final()); | 656 | |
| 657 | } | 657 | pub const Crc21CanFd = Crc(u21, .{ |
| 658 | | 658 | .polynomial = 0x102899, |
| 659 | const crc_16_cdma2000: Algorithm(u16) = .{ .poly = 0xc867, .init = 0xffff, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x4c06, .residue = 0x0000 }; | 659 | .initial = 0x000000, |
| 660 | | 660 | .reflect_input = false, |
| 661 | pub const Crc16Cdma2000 = Crc(u16, crc_16_cdma2000); | 661 | .reflect_output = false, |
| 662 | | 662 | .xor_output = 0x000000, |
| 663 | test "CRC-16/CDMA2000" { | 663 | }); |
| 664 | try testing.expectEqual(crc_16_cdma2000.check, Crc16Cdma2000.hash("123456789")); | 664 | |
| 665 | | 665 | pub const Crc24Ble = Crc(u24, .{ |
| 666 | var c = Crc16Cdma2000.init(); | 666 | .polynomial = 0x00065b, |
| 667 | c.update("1234"); | 667 | .initial = 0x555555, |
| 668 | c.update("56789"); | 668 | .reflect_input = true, |
| 669 | try testing.expectEqual(crc_16_cdma2000.check, c.final()); | 669 | .reflect_output = true, |
| 670 | } | 670 | .xor_output = 0x000000, |
| 671 | | 671 | }); |
| 672 | const crc_16_cms: Algorithm(u16) = .{ .poly = 0x8005, .init = 0xffff, .refin = false, .refout = false, .xorout = 0x0000, .check = 0xaee7, .residue = 0x0000 }; | 672 | |
| 673 | | 673 | pub const Crc24FlexrayA = Crc(u24, .{ |
| 674 | pub const Crc16Cms = Crc(u16, crc_16_cms); | 674 | .polynomial = 0x5d6dcb, |
| 675 | | 675 | .initial = 0xfedcba, |
| 676 | test "CRC-16/CMS" { | 676 | .reflect_input = false, |
| 677 | try testing.expectEqual(crc_16_cms.check, Crc16Cms.hash("123456789")); | 677 | .reflect_output = false, |
| 678 | | 678 | .xor_output = 0x000000, |
| 679 | var c = Crc16Cms.init(); | 679 | }); |
| 680 | c.update("1234"); | 680 | |
| 681 | c.update("56789"); | 681 | pub const Crc24FlexrayB = Crc(u24, .{ |
| 682 | try testing.expectEqual(crc_16_cms.check, c.final()); | 682 | .polynomial = 0x5d6dcb, |
| 683 | } | 683 | .initial = 0xabcdef, |
| 684 | | 684 | .reflect_input = false, |
| 685 | const crc_16_dds_110: Algorithm(u16) = .{ .poly = 0x8005, .init = 0x800d, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x9ecf, .residue = 0x0000 }; | 685 | .reflect_output = false, |
| 686 | | 686 | .xor_output = 0x000000, |
| 687 | pub const Crc16Dds110 = Crc(u16, crc_16_dds_110); | 687 | }); |
| 688 | | 688 | |
| 689 | test "CRC-16/DDS-110" { | 689 | pub const Crc24Interlaken = Crc(u24, .{ |
| 690 | try testing.expectEqual(crc_16_dds_110.check, Crc16Dds110.hash("123456789")); | 690 | .polynomial = 0x328b63, |
| 691 | | 691 | .initial = 0xffffff, |
| 692 | var c = Crc16Dds110.init(); | 692 | .reflect_input = false, |
| 693 | c.update("1234"); | 693 | .reflect_output = false, |
| 694 | c.update("56789"); | 694 | .xor_output = 0xffffff, |
| 695 | try testing.expectEqual(crc_16_dds_110.check, c.final()); | 695 | }); |
| 696 | } | 696 | |
| 697 | | 697 | pub const Crc24LteA = Crc(u24, .{ |
| 698 | const crc_16_dect_r: Algorithm(u16) = .{ .poly = 0x0589, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0001, .check = 0x007e, .residue = 0x0589 }; | 698 | .polynomial = 0x864cfb, |
| 699 | | 699 | .initial = 0x000000, |
| 700 | pub const Crc16DectR = Crc(u16, crc_16_dect_r); | 700 | .reflect_input = false, |
| 701 | | 701 | .reflect_output = false, |
| 702 | test "CRC-16/DECT-R" { | 702 | .xor_output = 0x000000, |
| 703 | try testing.expectEqual(crc_16_dect_r.check, Crc16DectR.hash("123456789")); | 703 | }); |
| 704 | | 704 | |
| 705 | var c = Crc16DectR.init(); | 705 | pub const Crc24LteB = Crc(u24, .{ |
| 706 | c.update("1234"); | 706 | .polynomial = 0x800063, |
| 707 | c.update("56789"); | 707 | .initial = 0x000000, |
| 708 | try testing.expectEqual(crc_16_dect_r.check, c.final()); | 708 | .reflect_input = false, |
| 709 | } | 709 | .reflect_output = false, |
| 710 | | 710 | .xor_output = 0x000000, |
| 711 | const crc_16_dect_x: Algorithm(u16) = .{ .poly = 0x0589, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x007f, .residue = 0x0000 }; | 711 | }); |
| 712 | | 712 | |
| 713 | pub const Crc16DectX = Crc(u16, crc_16_dect_x); | 713 | pub const Crc24Openpgp = Crc(u24, .{ |
| 714 | | 714 | .polynomial = 0x864cfb, |
| 715 | test "CRC-16/DECT-X" { | 715 | .initial = 0xb704ce, |
| 716 | try testing.expectEqual(crc_16_dect_x.check, Crc16DectX.hash("123456789")); | 716 | .reflect_input = false, |
| 717 | | 717 | .reflect_output = false, |
| 718 | var c = Crc16DectX.init(); | 718 | .xor_output = 0x000000, |
| 719 | c.update("1234"); | 719 | }); |
| 720 | c.update("56789"); | 720 | |
| 721 | try testing.expectEqual(crc_16_dect_x.check, c.final()); | 721 | pub const Crc24Os9 = Crc(u24, .{ |
| 722 | } | 722 | .polynomial = 0x800063, |
| 723 | | 723 | .initial = 0xffffff, |
| 724 | const crc_16_dnp: Algorithm(u16) = .{ .poly = 0x3d65, .init = 0x0000, .refin = true, .refout = true, .xorout = 0xffff, .check = 0xea82, .residue = 0x66c5 }; | 724 | .reflect_input = false, |
| 725 | | 725 | .reflect_output = false, |
| 726 | pub const Crc16Dnp = Crc(u16, crc_16_dnp); | 726 | .xor_output = 0xffffff, |
| 727 | | 727 | }); |
| 728 | test "CRC-16/DNP" { | 728 | |
| 729 | try testing.expectEqual(crc_16_dnp.check, Crc16Dnp.hash("123456789")); | 729 | pub const Crc30Cdma = Crc(u30, .{ |
| 730 | | 730 | .polynomial = 0x2030b9c7, |
| 731 | var c = Crc16Dnp.init(); | 731 | .initial = 0x3fffffff, |
| 732 | c.update("1234"); | 732 | .reflect_input = false, |
| 733 | c.update("56789"); | 733 | .reflect_output = false, |
| 734 | try testing.expectEqual(crc_16_dnp.check, c.final()); | 734 | .xor_output = 0x3fffffff, |
| 735 | } | 735 | }); |
| 736 | | 736 | |
| 737 | const crc_16_en_13757: Algorithm(u16) = .{ .poly = 0x3d65, .init = 0x0000, .refin = false, .refout = false, .xorout = 0xffff, .check = 0xc2b7, .residue = 0xa366 }; | 737 | pub const Crc31Philips = Crc(u31, .{ |
| 738 | | 738 | .polynomial = 0x04c11db7, |
| 739 | pub const Crc16En13757 = Crc(u16, crc_16_en_13757); | 739 | .initial = 0x7fffffff, |
| 740 | | 740 | .reflect_input = false, |
| 741 | test "CRC-16/EN-13757" { | 741 | .reflect_output = false, |
| 742 | try testing.expectEqual(crc_16_en_13757.check, Crc16En13757.hash("123456789")); | 742 | .xor_output = 0x7fffffff, |
| 743 | | 743 | }); |
| 744 | var c = Crc16En13757.init(); | 744 | |
| 745 | c.update("1234"); | 745 | pub const Crc32Aixm = Crc(u32, .{ |
| 746 | c.update("56789"); | 746 | .polynomial = 0x814141ab, |
| 747 | try testing.expectEqual(crc_16_en_13757.check, c.final()); | 747 | .initial = 0x00000000, |
| 748 | } | 748 | .reflect_input = false, |
| 749 | | 749 | .reflect_output = false, |
| 750 | const crc_16_genibus: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xffff, .refin = false, .refout = false, .xorout = 0xffff, .check = 0xd64e, .residue = 0x1d0f }; | 750 | .xor_output = 0x00000000, |
| 751 | | 751 | }); |
| 752 | pub const Crc16Genibus = Crc(u16, crc_16_genibus); | 752 | |
| 753 | | 753 | pub const Crc32Autosar = Crc(u32, .{ |
| 754 | test "CRC-16/GENIBUS" { | 754 | .polynomial = 0xf4acfb13, |
| 755 | try testing.expectEqual(crc_16_genibus.check, Crc16Genibus.hash("123456789")); | 755 | .initial = 0xffffffff, |
| 756 | | 756 | .reflect_input = true, |
| 757 | var c = Crc16Genibus.init(); | 757 | .reflect_output = true, |
| 758 | c.update("1234"); | 758 | .xor_output = 0xffffffff, |
| 759 | c.update("56789"); | 759 | }); |
| 760 | try testing.expectEqual(crc_16_genibus.check, c.final()); | 760 | |
| 761 | } | 761 | pub const Crc32Base91D = Crc(u32, .{ |
| 762 | | 762 | .polynomial = 0xa833982b, |
| 763 | const crc_16_gsm: Algorithm(u16) = .{ .poly = 0x1021, .init = 0x0000, .refin = false, .refout = false, .xorout = 0xffff, .check = 0xce3c, .residue = 0x1d0f }; | 763 | .initial = 0xffffffff, |
| 764 | | 764 | .reflect_input = true, |
| 765 | pub const Crc16Gsm = Crc(u16, crc_16_gsm); | 765 | .reflect_output = true, |
| 766 | | 766 | .xor_output = 0xffffffff, |
| 767 | test "CRC-16/GSM" { | 767 | }); |
| 768 | try testing.expectEqual(crc_16_gsm.check, Crc16Gsm.hash("123456789")); | 768 | |
| 769 | | 769 | pub const Crc32Bzip2 = Crc(u32, .{ |
| 770 | var c = Crc16Gsm.init(); | 770 | .polynomial = 0x04c11db7, |
| 771 | c.update("1234"); | 771 | .initial = 0xffffffff, |
| 772 | c.update("56789"); | 772 | .reflect_input = false, |
| 773 | try testing.expectEqual(crc_16_gsm.check, c.final()); | 773 | .reflect_output = false, |
| 774 | } | 774 | .xor_output = 0xffffffff, |
| 775 | | 775 | }); |
| 776 | const crc_16_ibm_3740: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xffff, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x29b1, .residue = 0x0000 }; | 776 | |
| 777 | | 777 | pub const Crc32CdRomEdc = Crc(u32, .{ |
| 778 | pub const Crc16Ibm3740 = Crc(u16, crc_16_ibm_3740); | 778 | .polynomial = 0x8001801b, |
| 779 | | 779 | .initial = 0x00000000, |
| 780 | test "CRC-16/IBM-3740" { | 780 | .reflect_input = true, |
| 781 | try testing.expectEqual(crc_16_ibm_3740.check, Crc16Ibm3740.hash("123456789")); | 781 | .reflect_output = true, |
| 782 | | 782 | .xor_output = 0x00000000, |
| 783 | var c = Crc16Ibm3740.init(); | 783 | }); |
| 784 | c.update("1234"); | 784 | |
| 785 | c.update("56789"); | 785 | pub const Crc32Cksum = Crc(u32, .{ |
| 786 | try testing.expectEqual(crc_16_ibm_3740.check, c.final()); | 786 | .polynomial = 0x04c11db7, |
| 787 | } | 787 | .initial = 0x00000000, |
| 788 | | 788 | .reflect_input = false, |
| 789 | const crc_16_ibm_sdlc: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xffff, .refin = true, .refout = true, .xorout = 0xffff, .check = 0x906e, .residue = 0xf0b8 }; | 789 | .reflect_output = false, |
| 790 | | 790 | .xor_output = 0xffffffff, |
| 791 | pub const Crc16IbmSdlc = Crc(u16, crc_16_ibm_sdlc); | 791 | }); |
| 792 | | 792 | |
| 793 | test "CRC-16/IBM-SDLC" { | 793 | pub const Crc32Iscsi = Crc(u32, .{ |
| 794 | try testing.expectEqual(crc_16_ibm_sdlc.check, Crc16IbmSdlc.hash("123456789")); | 794 | .polynomial = 0x1edc6f41, |
| 795 | | 795 | .initial = 0xffffffff, |
| 796 | var c = Crc16IbmSdlc.init(); | 796 | .reflect_input = true, |
| 797 | c.update("1234"); | 797 | .reflect_output = true, |
| 798 | c.update("56789"); | 798 | .xor_output = 0xffffffff, |
| 799 | try testing.expectEqual(crc_16_ibm_sdlc.check, c.final()); | 799 | }); |
| 800 | } | 800 | |
| 801 | | 801 | pub const Crc32IsoHdlc = Crc(u32, .{ |
| 802 | const crc_16_iso_iec_14443_3_a: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xc6c6, .refin = true, .refout = true, .xorout = 0x0000, .check = 0xbf05, .residue = 0x0000 }; | 802 | .polynomial = 0x04c11db7, |
| 803 | | 803 | .initial = 0xffffffff, |
| 804 | pub const Crc16IsoIec144433A = Crc(u16, crc_16_iso_iec_14443_3_a); | 804 | .reflect_input = true, |
| 805 | | 805 | .reflect_output = true, |
| 806 | test "CRC-16/ISO-IEC-14443-3-A" { | 806 | .xor_output = 0xffffffff, |
| 807 | try testing.expectEqual(crc_16_iso_iec_14443_3_a.check, Crc16IsoIec144433A.hash("123456789")); | 807 | }); |
| 808 | | 808 | |
| 809 | var c = Crc16IsoIec144433A.init(); | 809 | pub const Crc32Jamcrc = Crc(u32, .{ |
| 810 | c.update("1234"); | 810 | .polynomial = 0x04c11db7, |
| 811 | c.update("56789"); | 811 | .initial = 0xffffffff, |
| 812 | try testing.expectEqual(crc_16_iso_iec_14443_3_a.check, c.final()); | 812 | .reflect_input = true, |
| 813 | } | 813 | .reflect_output = true, |
| 814 | | 814 | .xor_output = 0x00000000, |
| 815 | const crc_16_kermit: Algorithm(u16) = .{ .poly = 0x1021, .init = 0x0000, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x2189, .residue = 0x0000 }; | 815 | }); |
| 816 | | 816 | |
| 817 | pub const Crc16Kermit = Crc(u16, crc_16_kermit); | 817 | pub const Crc32Mef = Crc(u32, .{ |
| 818 | | 818 | .polynomial = 0x741b8cd7, |
| 819 | test "CRC-16/KERMIT" { | 819 | .initial = 0xffffffff, |
| 820 | try testing.expectEqual(crc_16_kermit.check, Crc16Kermit.hash("123456789")); | 820 | .reflect_input = true, |
| 821 | | 821 | .reflect_output = true, |
| 822 | var c = Crc16Kermit.init(); | 822 | .xor_output = 0x00000000, |
| 823 | c.update("1234"); | 823 | }); |
| 824 | c.update("56789"); | 824 | |
| 825 | try testing.expectEqual(crc_16_kermit.check, c.final()); | 825 | pub const Crc32Mpeg2 = Crc(u32, .{ |
| 826 | } | 826 | .polynomial = 0x04c11db7, |
| 827 | | 827 | .initial = 0xffffffff, |
| 828 | const crc_16_lj1200: Algorithm(u16) = .{ .poly = 0x6f63, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0xbdf4, .residue = 0x0000 }; | 828 | .reflect_input = false, |
| 829 | | 829 | .reflect_output = false, |
| 830 | pub const Crc16Lj1200 = Crc(u16, crc_16_lj1200); | 830 | .xor_output = 0x00000000, |
| 831 | | 831 | }); |
| 832 | test "CRC-16/LJ1200" { | 832 | |
| 833 | try testing.expectEqual(crc_16_lj1200.check, Crc16Lj1200.hash("123456789")); | 833 | pub const Crc32Xfer = Crc(u32, .{ |
| 834 | | 834 | .polynomial = 0x000000af, |
| 835 | var c = Crc16Lj1200.init(); | 835 | .initial = 0x00000000, |
| 836 | c.update("1234"); | 836 | .reflect_input = false, |
| 837 | c.update("56789"); | 837 | .reflect_output = false, |
| 838 | try testing.expectEqual(crc_16_lj1200.check, c.final()); | 838 | .xor_output = 0x00000000, |
| 839 | } | 839 | }); |
| 840 | | 840 | |
| 841 | const crc_16_m17: Algorithm(u16) = .{ .poly = 0x5935, .init = 0xffff, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x772b, .residue = 0x0000 }; | 841 | pub const Crc40Gsm = Crc(u40, .{ |
| 842 | | 842 | .polynomial = 0x0004820009, |
| 843 | pub const Crc16M17 = Crc(u16, crc_16_m17); | 843 | .initial = 0x0000000000, |
| 844 | | 844 | .reflect_input = false, |
| 845 | test "CRC-16/M17" { | 845 | .reflect_output = false, |
| 846 | try testing.expectEqual(crc_16_m17.check, Crc16M17.hash("123456789")); | 846 | .xor_output = 0xffffffffff, |
| 847 | | 847 | }); |
| 848 | var c = Crc16M17.init(); | 848 | |
| 849 | c.update("1234"); | 849 | pub const Crc64Ecma182 = Crc(u64, .{ |
| 850 | c.update("56789"); | 850 | .polynomial = 0x42f0e1eba9ea3693, |
| 851 | try testing.expectEqual(crc_16_m17.check, c.final()); | 851 | .initial = 0x0000000000000000, |
| 852 | } | 852 | .reflect_input = false, |
| 853 | | 853 | .reflect_output = false, |
| 854 | const crc_16_maxim_dow: Algorithm(u16) = .{ .poly = 0x8005, .init = 0x0000, .refin = true, .refout = true, .xorout = 0xffff, .check = 0x44c2, .residue = 0xb001 }; | 854 | .xor_output = 0x0000000000000000, |
| 855 | | 855 | }); |
| 856 | pub const Crc16MaximDow = Crc(u16, crc_16_maxim_dow); | 856 | |
| 857 | | 857 | pub const Crc64GoIso = Crc(u64, .{ |
| 858 | test "CRC-16/MAXIM-DOW" { | 858 | .polynomial = 0x000000000000001b, |
| 859 | try testing.expectEqual(crc_16_maxim_dow.check, Crc16MaximDow.hash("123456789")); | 859 | .initial = 0xffffffffffffffff, |
| 860 | | 860 | .reflect_input = true, |
| 861 | var c = Crc16MaximDow.init(); | 861 | .reflect_output = true, |
| 862 | c.update("1234"); | 862 | .xor_output = 0xffffffffffffffff, |
| 863 | c.update("56789"); | 863 | }); |
| 864 | try testing.expectEqual(crc_16_maxim_dow.check, c.final()); | 864 | |
| 865 | } | 865 | pub const Crc64Ms = Crc(u64, .{ |
| 866 | | 866 | .polynomial = 0x259c84cba6426349, |
| 867 | const crc_16_mcrf4xx: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xffff, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x6f91, .residue = 0x0000 }; | 867 | .initial = 0xffffffffffffffff, |
| 868 | | 868 | .reflect_input = true, |
| 869 | pub const Crc16Mcrf4xx = Crc(u16, crc_16_mcrf4xx); | 869 | .reflect_output = true, |
| 870 | | 870 | .xor_output = 0x0000000000000000, |
| 871 | test "CRC-16/MCRF4XX" { | 871 | }); |
| 872 | try testing.expectEqual(crc_16_mcrf4xx.check, Crc16Mcrf4xx.hash("123456789")); | 872 | |
| 873 | | 873 | pub const Crc64Redis = Crc(u64, .{ |
| 874 | var c = Crc16Mcrf4xx.init(); | 874 | .polynomial = 0xad93d23594c935a9, |
| 875 | c.update("1234"); | 875 | .initial = 0x0000000000000000, |
| 876 | c.update("56789"); | 876 | .reflect_input = true, |
| 877 | try testing.expectEqual(crc_16_mcrf4xx.check, c.final()); | 877 | .reflect_output = true, |
| 878 | } | 878 | .xor_output = 0x0000000000000000, |
| 879 | | 879 | }); |
| 880 | const crc_16_modbus: Algorithm(u16) = .{ .poly = 0x8005, .init = 0xffff, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x4b37, .residue = 0x0000 }; | 880 | |
| 881 | | 881 | pub const Crc64We = Crc(u64, .{ |
| 882 | pub const Crc16Modbus = Crc(u16, crc_16_modbus); | 882 | .polynomial = 0x42f0e1eba9ea3693, |
| 883 | | 883 | .initial = 0xffffffffffffffff, |
| 884 | test "CRC-16/MODBUS" { | 884 | .reflect_input = false, |
| 885 | try testing.expectEqual(crc_16_modbus.check, Crc16Modbus.hash("123456789")); | 885 | .reflect_output = false, |
| 886 | | 886 | .xor_output = 0xffffffffffffffff, |
| 887 | var c = Crc16Modbus.init(); | 887 | }); |
| 888 | c.update("1234"); | 888 | |
| 889 | c.update("56789"); | 889 | pub const Crc64Xz = Crc(u64, .{ |
| 890 | try testing.expectEqual(crc_16_modbus.check, c.final()); | 890 | .polynomial = 0x42f0e1eba9ea3693, |
| 891 | } | 891 | .initial = 0xffffffffffffffff, |
| 892 | | 892 | .reflect_input = true, |
| 893 | const crc_16_nrsc_5: Algorithm(u16) = .{ .poly = 0x080b, .init = 0xffff, .refin = true, .refout = true, .xorout = 0x0000, .check = 0xa066, .residue = 0x0000 }; | 893 | .reflect_output = true, |
| 894 | | 894 | .xor_output = 0xffffffffffffffff, |
| 895 | pub const Crc16Nrsc5 = Crc(u16, crc_16_nrsc_5); | 895 | }); |
| 896 | | 896 | |
| 897 | test "CRC-16/NRSC-5" { | 897 | pub const Crc82Darc = Crc(u82, .{ |
| 898 | try testing.expectEqual(crc_16_nrsc_5.check, Crc16Nrsc5.hash("123456789")); | 898 | .polynomial = 0x0308c0111011401440411, |
| 899 | | 899 | .initial = 0x000000000000000000000, |
| 900 | var c = Crc16Nrsc5.init(); | 900 | .reflect_input = true, |
| 901 | c.update("1234"); | 901 | .reflect_output = true, |
| 902 | c.update("56789"); | 902 | .xor_output = 0x000000000000000000000, |
| 903 | try testing.expectEqual(crc_16_nrsc_5.check, c.final()); | 903 | }); |
| 904 | } | | |
| 905 | | | |
| 906 | const crc_16_opensafety_a: Algorithm(u16) = .{ .poly = 0x5935, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x5d38, .residue = 0x0000 }; | | |
| 907 | | | |
| 908 | pub const Crc16OpensafetyA = Crc(u16, crc_16_opensafety_a); | | |
| 909 | | | |
| 910 | test "CRC-16/OPENSAFETY-A" { | | |
| 911 | try testing.expectEqual(crc_16_opensafety_a.check, Crc16OpensafetyA.hash("123456789")); | | |
| 912 | | | |
| 913 | var c = Crc16OpensafetyA.init(); | | |
| 914 | c.update("1234"); | | |
| 915 | c.update("56789"); | | |
| 916 | try testing.expectEqual(crc_16_opensafety_a.check, c.final()); | | |
| 917 | } | | |
| 918 | | | |
| 919 | const crc_16_opensafety_b: Algorithm(u16) = .{ .poly = 0x755b, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x20fe, .residue = 0x0000 }; | | |
| 920 | | | |
| 921 | pub const Crc16OpensafetyB = Crc(u16, crc_16_opensafety_b); | | |
| 922 | | | |
| 923 | test "CRC-16/OPENSAFETY-B" { | | |
| 924 | try testing.expectEqual(crc_16_opensafety_b.check, Crc16OpensafetyB.hash("123456789")); | | |
| 925 | | | |
| 926 | var c = Crc16OpensafetyB.init(); | | |
| 927 | c.update("1234"); | | |
| 928 | c.update("56789"); | | |
| 929 | try testing.expectEqual(crc_16_opensafety_b.check, c.final()); | | |
| 930 | } | | |
| 931 | | | |
| 932 | const crc_16_profibus: Algorithm(u16) = .{ .poly = 0x1dcf, .init = 0xffff, .refin = false, .refout = false, .xorout = 0xffff, .check = 0xa819, .residue = 0xe394 }; | | |
| 933 | | | |
| 934 | pub const Crc16Profibus = Crc(u16, crc_16_profibus); | | |
| 935 | | | |
| 936 | test "CRC-16/PROFIBUS" { | | |
| 937 | try testing.expectEqual(crc_16_profibus.check, Crc16Profibus.hash("123456789")); | | |
| 938 | | | |
| 939 | var c = Crc16Profibus.init(); | | |
| 940 | c.update("1234"); | | |
| 941 | c.update("56789"); | | |
| 942 | try testing.expectEqual(crc_16_profibus.check, c.final()); | | |
| 943 | } | | |
| 944 | | | |
| 945 | const crc_16_riello: Algorithm(u16) = .{ .poly = 0x1021, .init = 0xb2aa, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x63d0, .residue = 0x0000 }; | | |
| 946 | | | |
| 947 | pub const Crc16Riello = Crc(u16, crc_16_riello); | | |
| 948 | | | |
| 949 | test "CRC-16/RIELLO" { | | |
| 950 | try testing.expectEqual(crc_16_riello.check, Crc16Riello.hash("123456789")); | | |
| 951 | | | |
| 952 | var c = Crc16Riello.init(); | | |
| 953 | c.update("1234"); | | |
| 954 | c.update("56789"); | | |
| 955 | try testing.expectEqual(crc_16_riello.check, c.final()); | | |
| 956 | } | | |
| 957 | | | |
| 958 | const crc_16_spi_fujitsu: Algorithm(u16) = .{ .poly = 0x1021, .init = 0x1d0f, .refin = false, .refout = false, .xorout = 0x0000, .check = 0xe5cc, .residue = 0x0000 }; | | |
| 959 | | | |
| 960 | pub const Crc16SpiFujitsu = Crc(u16, crc_16_spi_fujitsu); | | |
| 961 | | | |
| 962 | test "CRC-16/SPI-FUJITSU" { | | |
| 963 | try testing.expectEqual(crc_16_spi_fujitsu.check, Crc16SpiFujitsu.hash("123456789")); | | |
| 964 | | | |
| 965 | var c = Crc16SpiFujitsu.init(); | | |
| 966 | c.update("1234"); | | |
| 967 | c.update("56789"); | | |
| 968 | try testing.expectEqual(crc_16_spi_fujitsu.check, c.final()); | | |
| 969 | } | | |
| 970 | | | |
| 971 | const crc_16_t10_dif: Algorithm(u16) = .{ .poly = 0x8bb7, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0xd0db, .residue = 0x0000 }; | | |
| 972 | | | |
| 973 | pub const Crc16T10Dif = Crc(u16, crc_16_t10_dif); | | |
| 974 | | | |
| 975 | test "CRC-16/T10-DIF" { | | |
| 976 | try testing.expectEqual(crc_16_t10_dif.check, Crc16T10Dif.hash("123456789")); | | |
| 977 | | | |
| 978 | var c = Crc16T10Dif.init(); | | |
| 979 | c.update("1234"); | | |
| 980 | c.update("56789"); | | |
| 981 | try testing.expectEqual(crc_16_t10_dif.check, c.final()); | | |
| 982 | } | | |
| 983 | | | |
| 984 | const crc_16_teledisk: Algorithm(u16) = .{ .poly = 0xa097, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x0fb3, .residue = 0x0000 }; | | |
| 985 | | | |
| 986 | pub const Crc16Teledisk = Crc(u16, crc_16_teledisk); | | |
| 987 | | | |
| 988 | test "CRC-16/TELEDISK" { | | |
| 989 | try testing.expectEqual(crc_16_teledisk.check, Crc16Teledisk.hash("123456789")); | | |
| 990 | | | |
| 991 | var c = Crc16Teledisk.init(); | | |
| 992 | c.update("1234"); | | |
| 993 | c.update("56789"); | | |
| 994 | try testing.expectEqual(crc_16_teledisk.check, c.final()); | | |
| 995 | } | | |
| 996 | | | |
| 997 | const crc_16_tms37157: Algorithm(u16) = .{ .poly = 0x1021, .init = 0x89ec, .refin = true, .refout = true, .xorout = 0x0000, .check = 0x26b1, .residue = 0x0000 }; | | |
| 998 | | | |
| 999 | pub const Crc16Tms37157 = Crc(u16, crc_16_tms37157); | | |
| 1000 | | | |
| 1001 | test "CRC-16/TMS37157" { | | |
| 1002 | try testing.expectEqual(crc_16_tms37157.check, Crc16Tms37157.hash("123456789")); | | |
| 1003 | | | |
| 1004 | var c = Crc16Tms37157.init(); | | |
| 1005 | c.update("1234"); | | |
| 1006 | c.update("56789"); | | |
| 1007 | try testing.expectEqual(crc_16_tms37157.check, c.final()); | | |
| 1008 | } | | |
| 1009 | | | |
| 1010 | const crc_16_umts: Algorithm(u16) = .{ .poly = 0x8005, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0xfee8, .residue = 0x0000 }; | | |
| 1011 | | | |
| 1012 | pub const Crc16Umts = Crc(u16, crc_16_umts); | | |
| 1013 | | | |
| 1014 | test "CRC-16/UMTS" { | | |
| 1015 | try testing.expectEqual(crc_16_umts.check, Crc16Umts.hash("123456789")); | | |
| 1016 | | | |
| 1017 | var c = Crc16Umts.init(); | | |
| 1018 | c.update("1234"); | | |
| 1019 | c.update("56789"); | | |
| 1020 | try testing.expectEqual(crc_16_umts.check, c.final()); | | |
| 1021 | } | | |
| 1022 | | | |
| 1023 | const crc_16_usb: Algorithm(u16) = .{ .poly = 0x8005, .init = 0xffff, .refin = true, .refout = true, .xorout = 0xffff, .check = 0xb4c8, .residue = 0xb001 }; | | |
| 1024 | | | |
| 1025 | pub const Crc16Usb = Crc(u16, crc_16_usb); | | |
| 1026 | | | |
| 1027 | test "CRC-16/USB" { | | |
| 1028 | try testing.expectEqual(crc_16_usb.check, Crc16Usb.hash("123456789")); | | |
| 1029 | | | |
| 1030 | var c = Crc16Usb.init(); | | |
| 1031 | c.update("1234"); | | |
| 1032 | c.update("56789"); | | |
| 1033 | try testing.expectEqual(crc_16_usb.check, c.final()); | | |
| 1034 | } | | |
| 1035 | | | |
| 1036 | const crc_16_xmodem: Algorithm(u16) = .{ .poly = 0x1021, .init = 0x0000, .refin = false, .refout = false, .xorout = 0x0000, .check = 0x31c3, .residue = 0x0000 }; | | |
| 1037 | | | |
| 1038 | pub const Crc16Xmodem = Crc(u16, crc_16_xmodem); | | |
| 1039 | | | |
| 1040 | test "CRC-16/XMODEM" { | | |
| 1041 | try testing.expectEqual(crc_16_xmodem.check, Crc16Xmodem.hash("123456789")); | | |
| 1042 | | | |
| 1043 | var c = Crc16Xmodem.init(); | | |
| 1044 | c.update("1234"); | | |
| 1045 | c.update("56789"); | | |
| 1046 | try testing.expectEqual(crc_16_xmodem.check, c.final()); | | |
| 1047 | } | | |
| 1048 | | | |
| 1049 | const crc_17_can_fd: Algorithm(u17) = .{ .poly = 0x1685b, .init = 0x00000, .refin = false, .refout = false, .xorout = 0x00000, .check = 0x04f03, .residue = 0x00000 }; | | |
| 1050 | | | |
| 1051 | pub const Crc17CanFd = Crc(u17, crc_17_can_fd); | | |
| 1052 | | | |
| 1053 | test "CRC-17/CAN-FD" { | | |
| 1054 | try testing.expectEqual(crc_17_can_fd.check, Crc17CanFd.hash("123456789")); | | |
| 1055 | | | |
| 1056 | var c = Crc17CanFd.init(); | | |
| 1057 | c.update("1234"); | | |
| 1058 | c.update("56789"); | | |
| 1059 | try testing.expectEqual(crc_17_can_fd.check, c.final()); | | |
| 1060 | } | | |
| 1061 | | | |
| 1062 | const crc_21_can_fd: Algorithm(u21) = .{ .poly = 0x102899, .init = 0x000000, .refin = false, .refout = false, .xorout = 0x000000, .check = 0x0ed841, .residue = 0x000000 }; | | |
| 1063 | | | |
| 1064 | pub const Crc21CanFd = Crc(u21, crc_21_can_fd); | | |
| 1065 | | | |
| 1066 | test "CRC-21/CAN-FD" { | | |
| 1067 | try testing.expectEqual(crc_21_can_fd.check, Crc21CanFd.hash("123456789")); | | |
| 1068 | | | |
| 1069 | var c = Crc21CanFd.init(); | | |
| 1070 | c.update("1234"); | | |
| 1071 | c.update("56789"); | | |
| 1072 | try testing.expectEqual(crc_21_can_fd.check, c.final()); | | |
| 1073 | } | | |
| 1074 | | | |
| 1075 | const crc_24_ble: Algorithm(u24) = .{ .poly = 0x00065b, .init = 0x555555, .refin = true, .refout = true, .xorout = 0x000000, .check = 0xc25a56, .residue = 0x000000 }; | | |
| 1076 | | | |
| 1077 | pub const Crc24Ble = Crc(u24, crc_24_ble); | | |
| 1078 | | | |
| 1079 | test "CRC-24/BLE" { | | |
| 1080 | try testing.expectEqual(crc_24_ble.check, Crc24Ble.hash("123456789")); | | |
| 1081 | | | |
| 1082 | var c = Crc24Ble.init(); | | |
| 1083 | c.update("1234"); | | |
| 1084 | c.update("56789"); | | |
| 1085 | try testing.expectEqual(crc_24_ble.check, c.final()); | | |
| 1086 | } | | |
| 1087 | | | |
| 1088 | const crc_24_flexray_a: Algorithm(u24) = .{ .poly = 0x5d6dcb, .init = 0xfedcba, .refin = false, .refout = false, .xorout = 0x000000, .check = 0x7979bd, .residue = 0x000000 }; | | |
| 1089 | | | |
| 1090 | pub const Crc24FlexrayA = Crc(u24, crc_24_flexray_a); | | |
| 1091 | | | |
| 1092 | test "CRC-24/FLEXRAY-A" { | | |
| 1093 | try testing.expectEqual(crc_24_flexray_a.check, Crc24FlexrayA.hash("123456789")); | | |
| 1094 | | | |
| 1095 | var c = Crc24FlexrayA.init(); | | |
| 1096 | c.update("1234"); | | |
| 1097 | c.update("56789"); | | |
| 1098 | try testing.expectEqual(crc_24_flexray_a.check, c.final()); | | |
| 1099 | } | | |
| 1100 | | | |
| 1101 | const crc_24_flexray_b: Algorithm(u24) = .{ .poly = 0x5d6dcb, .init = 0xabcdef, .refin = false, .refout = false, .xorout = 0x000000, .check = 0x1f23b8, .residue = 0x000000 }; | | |
| 1102 | | | |
| 1103 | pub const Crc24FlexrayB = Crc(u24, crc_24_flexray_b); | | |
| 1104 | | | |
| 1105 | test "CRC-24/FLEXRAY-B" { | | |
| 1106 | try testing.expectEqual(crc_24_flexray_b.check, Crc24FlexrayB.hash("123456789")); | | |
| 1107 | | | |
| 1108 | var c = Crc24FlexrayB.init(); | | |
| 1109 | c.update("1234"); | | |
| 1110 | c.update("56789"); | | |
| 1111 | try testing.expectEqual(crc_24_flexray_b.check, c.final()); | | |
| 1112 | } | | |
| 1113 | | | |
| 1114 | const crc_24_interlaken: Algorithm(u24) = .{ .poly = 0x328b63, .init = 0xffffff, .refin = false, .refout = false, .xorout = 0xffffff, .check = 0xb4f3e6, .residue = 0x144e63 }; | | |
| 1115 | | | |
| 1116 | pub const Crc24Interlaken = Crc(u24, crc_24_interlaken); | | |
| 1117 | | | |
| 1118 | test "CRC-24/INTERLAKEN" { | | |
| 1119 | try testing.expectEqual(crc_24_interlaken.check, Crc24Interlaken.hash("123456789")); | | |
| 1120 | | | |
| 1121 | var c = Crc24Interlaken.init(); | | |
| 1122 | c.update("1234"); | | |
| 1123 | c.update("56789"); | | |
| 1124 | try testing.expectEqual(crc_24_interlaken.check, c.final()); | | |
| 1125 | } | | |
| 1126 | | | |
| 1127 | const crc_24_lte_a: Algorithm(u24) = .{ .poly = 0x864cfb, .init = 0x000000, .refin = false, .refout = false, .xorout = 0x000000, .check = 0xcde703, .residue = 0x000000 }; | | |
| 1128 | | | |
| 1129 | pub const Crc24LteA = Crc(u24, crc_24_lte_a); | | |
| 1130 | | | |
| 1131 | test "CRC-24/LTE-A" { | | |
| 1132 | try testing.expectEqual(crc_24_lte_a.check, Crc24LteA.hash("123456789")); | | |
| 1133 | | | |
| 1134 | var c = Crc24LteA.init(); | | |
| 1135 | c.update("1234"); | | |
| 1136 | c.update("56789"); | | |
| 1137 | try testing.expectEqual(crc_24_lte_a.check, c.final()); | | |
| 1138 | } | | |
| 1139 | | | |
| 1140 | const crc_24_lte_b: Algorithm(u24) = .{ .poly = 0x800063, .init = 0x000000, .refin = false, .refout = false, .xorout = 0x000000, .check = 0x23ef52, .residue = 0x000000 }; | | |
| 1141 | | | |
| 1142 | pub const Crc24LteB = Crc(u24, crc_24_lte_b); | | |
| 1143 | | | |
| 1144 | test "CRC-24/LTE-B" { | | |
| 1145 | try testing.expectEqual(crc_24_lte_b.check, Crc24LteB.hash("123456789")); | | |
| 1146 | | | |
| 1147 | var c = Crc24LteB.init(); | | |
| 1148 | c.update("1234"); | | |
| 1149 | c.update("56789"); | | |
| 1150 | try testing.expectEqual(crc_24_lte_b.check, c.final()); | | |
| 1151 | } | | |
| 1152 | | | |
| 1153 | const crc_24_openpgp: Algorithm(u24) = .{ .poly = 0x864cfb, .init = 0xb704ce, .refin = false, .refout = false, .xorout = 0x000000, .check = 0x21cf02, .residue = 0x000000 }; | | |
| 1154 | | | |
| 1155 | pub const Crc24Openpgp = Crc(u24, crc_24_openpgp); | | |
| 1156 | | | |
| 1157 | test "CRC-24/OPENPGP" { | | |
| 1158 | try testing.expectEqual(crc_24_openpgp.check, Crc24Openpgp.hash("123456789")); | | |
| 1159 | | | |
| 1160 | var c = Crc24Openpgp.init(); | | |
| 1161 | c.update("1234"); | | |
| 1162 | c.update("56789"); | | |
| 1163 | try testing.expectEqual(crc_24_openpgp.check, c.final()); | | |
| 1164 | } | | |
| 1165 | | | |
| 1166 | const crc_24_os_9: Algorithm(u24) = .{ .poly = 0x800063, .init = 0xffffff, .refin = false, .refout = false, .xorout = 0xffffff, .check = 0x200fa5, .residue = 0x800fe3 }; | | |
| 1167 | | | |
| 1168 | pub const Crc24Os9 = Crc(u24, crc_24_os_9); | | |
| 1169 | | | |
| 1170 | test "CRC-24/OS-9" { | | |
| 1171 | try testing.expectEqual(crc_24_os_9.check, Crc24Os9.hash("123456789")); | | |
| 1172 | | | |
| 1173 | var c = Crc24Os9.init(); | | |
| 1174 | c.update("1234"); | | |
| 1175 | c.update("56789"); | | |
| 1176 | try testing.expectEqual(crc_24_os_9.check, c.final()); | | |
| 1177 | } | | |
| 1178 | | | |
| 1179 | const crc_30_cdma: Algorithm(u30) = .{ .poly = 0x2030b9c7, .init = 0x3fffffff, .refin = false, .refout = false, .xorout = 0x3fffffff, .check = 0x04c34abf, .residue = 0x34efa55a }; | | |
| 1180 | | | |
| 1181 | pub const Crc30Cdma = Crc(u30, crc_30_cdma); | | |
| 1182 | | | |
| 1183 | test "CRC-30/CDMA" { | | |
| 1184 | try testing.expectEqual(crc_30_cdma.check, Crc30Cdma.hash("123456789")); | | |
| 1185 | | | |
| 1186 | var c = Crc30Cdma.init(); | | |
| 1187 | c.update("1234"); | | |
| 1188 | c.update("56789"); | | |
| 1189 | try testing.expectEqual(crc_30_cdma.check, c.final()); | | |
| 1190 | } | | |
| 1191 | | | |
| 1192 | const crc_31_philips: Algorithm(u31) = .{ .poly = 0x04c11db7, .init = 0x7fffffff, .refin = false, .refout = false, .xorout = 0x7fffffff, .check = 0x0ce9e46c, .residue = 0x4eaf26f1 }; | | |
| 1193 | | | |
| 1194 | pub const Crc31Philips = Crc(u31, crc_31_philips); | | |
| 1195 | | | |
| 1196 | test "CRC-31/PHILIPS" { | | |
| 1197 | try testing.expectEqual(crc_31_philips.check, Crc31Philips.hash("123456789")); | | |
| 1198 | | | |
| 1199 | var c = Crc31Philips.init(); | | |
| 1200 | c.update("1234"); | | |
| 1201 | c.update("56789"); | | |
| 1202 | try testing.expectEqual(crc_31_philips.check, c.final()); | | |
| 1203 | } | | |
| 1204 | | | |
| 1205 | const crc_32_aixm: Algorithm(u32) = .{ .poly = 0x814141ab, .init = 0x00000000, .refin = false, .refout = false, .xorout = 0x00000000, .check = 0x3010bf7f, .residue = 0x00000000 }; | | |
| 1206 | | | |
| 1207 | pub const Crc32Aixm = Crc(u32, crc_32_aixm); | | |
| 1208 | | | |
| 1209 | test "CRC-32/AIXM" { | | |
| 1210 | try testing.expectEqual(crc_32_aixm.check, Crc32Aixm.hash("123456789")); | | |
| 1211 | | | |
| 1212 | var c = Crc32Aixm.init(); | | |
| 1213 | c.update("1234"); | | |
| 1214 | c.update("56789"); | | |
| 1215 | try testing.expectEqual(crc_32_aixm.check, c.final()); | | |
| 1216 | } | | |
| 1217 | | | |
| 1218 | const crc_32_autosar: Algorithm(u32) = .{ .poly = 0xf4acfb13, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0xffffffff, .check = 0x1697d06a, .residue = 0x904cddbf }; | | |
| 1219 | | | |
| 1220 | pub const Crc32Autosar = Crc(u32, crc_32_autosar); | | |
| 1221 | | | |
| 1222 | test "CRC-32/AUTOSAR" { | | |
| 1223 | try testing.expectEqual(crc_32_autosar.check, Crc32Autosar.hash("123456789")); | | |
| 1224 | | | |
| 1225 | var c = Crc32Autosar.init(); | | |
| 1226 | c.update("1234"); | | |
| 1227 | c.update("56789"); | | |
| 1228 | try testing.expectEqual(crc_32_autosar.check, c.final()); | | |
| 1229 | } | | |
| 1230 | | | |
| 1231 | const crc_32_base91_d: Algorithm(u32) = .{ .poly = 0xa833982b, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0xffffffff, .check = 0x87315576, .residue = 0x45270551 }; | | |
| 1232 | | | |
| 1233 | pub const Crc32Base91D = Crc(u32, crc_32_base91_d); | | |
| 1234 | | | |
| 1235 | test "CRC-32/BASE91-D" { | | |
| 1236 | try testing.expectEqual(crc_32_base91_d.check, Crc32Base91D.hash("123456789")); | | |
| 1237 | | | |
| 1238 | var c = Crc32Base91D.init(); | | |
| 1239 | c.update("1234"); | | |
| 1240 | c.update("56789"); | | |
| 1241 | try testing.expectEqual(crc_32_base91_d.check, c.final()); | | |
| 1242 | } | | |
| 1243 | | | |
| 1244 | const crc_32_bzip2: Algorithm(u32) = .{ .poly = 0x04c11db7, .init = 0xffffffff, .refin = false, .refout = false, .xorout = 0xffffffff, .check = 0xfc891918, .residue = 0xc704dd7b }; | | |
| 1245 | | | |
| 1246 | pub const Crc32Bzip2 = Crc(u32, crc_32_bzip2); | | |
| 1247 | | | |
| 1248 | test "CRC-32/BZIP2" { | | |
| 1249 | try testing.expectEqual(crc_32_bzip2.check, Crc32Bzip2.hash("123456789")); | | |
| 1250 | | | |
| 1251 | var c = Crc32Bzip2.init(); | | |
| 1252 | c.update("1234"); | | |
| 1253 | c.update("56789"); | | |
| 1254 | try testing.expectEqual(crc_32_bzip2.check, c.final()); | | |
| 1255 | } | | |
| 1256 | | | |
| 1257 | const crc_32_cd_rom_edc: Algorithm(u32) = .{ .poly = 0x8001801b, .init = 0x00000000, .refin = true, .refout = true, .xorout = 0x00000000, .check = 0x6ec2edc4, .residue = 0x00000000 }; | | |
| 1258 | | | |
| 1259 | pub const Crc32CdRomEdc = Crc(u32, crc_32_cd_rom_edc); | | |
| 1260 | | | |
| 1261 | test "CRC-32/CD-ROM-EDC" { | | |
| 1262 | try testing.expectEqual(crc_32_cd_rom_edc.check, Crc32CdRomEdc.hash("123456789")); | | |
| 1263 | | | |
| 1264 | var c = Crc32CdRomEdc.init(); | | |
| 1265 | c.update("1234"); | | |
| 1266 | c.update("56789"); | | |
| 1267 | try testing.expectEqual(crc_32_cd_rom_edc.check, c.final()); | | |
| 1268 | } | | |
| 1269 | | | |
| 1270 | const crc_32_cksum: Algorithm(u32) = .{ .poly = 0x04c11db7, .init = 0x00000000, .refin = false, .refout = false, .xorout = 0xffffffff, .check = 0x765e7680, .residue = 0xc704dd7b }; | | |
| 1271 | | | |
| 1272 | pub const Crc32Cksum = Crc(u32, crc_32_cksum); | | |
| 1273 | | | |
| 1274 | test "CRC-32/CKSUM" { | | |
| 1275 | try testing.expectEqual(crc_32_cksum.check, Crc32Cksum.hash("123456789")); | | |
| 1276 | | | |
| 1277 | var c = Crc32Cksum.init(); | | |
| 1278 | c.update("1234"); | | |
| 1279 | c.update("56789"); | | |
| 1280 | try testing.expectEqual(crc_32_cksum.check, c.final()); | | |
| 1281 | } | | |
| 1282 | | | |
| 1283 | const crc_32_iscsi: Algorithm(u32) = .{ .poly = 0x1edc6f41, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0xffffffff, .check = 0xe3069283, .residue = 0xb798b438 }; | | |
| 1284 | | | |
| 1285 | pub const Crc32Iscsi = Crc(u32, crc_32_iscsi); | | |
| 1286 | | | |
| 1287 | test "CRC-32/ISCSI" { | | |
| 1288 | try testing.expectEqual(crc_32_iscsi.check, Crc32Iscsi.hash("123456789")); | | |
| 1289 | | | |
| 1290 | var c = Crc32Iscsi.init(); | | |
| 1291 | c.update("1234"); | | |
| 1292 | c.update("56789"); | | |
| 1293 | try testing.expectEqual(crc_32_iscsi.check, c.final()); | | |
| 1294 | } | | |
| 1295 | | | |
| 1296 | const crc_32_iso_hdlc: Algorithm(u32) = .{ .poly = 0x04c11db7, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0xffffffff, .check = 0xcbf43926, .residue = 0xdebb20e3 }; | | |
| 1297 | | | |
| 1298 | pub const Crc32IsoHdlc = Crc(u32, crc_32_iso_hdlc); | | |
| 1299 | | | |
| 1300 | test "CRC-32/ISO-HDLC" { | | |
| 1301 | try testing.expectEqual(crc_32_iso_hdlc.check, Crc32IsoHdlc.hash("123456789")); | | |
| 1302 | | | |
| 1303 | var c = Crc32IsoHdlc.init(); | | |
| 1304 | c.update("1234"); | | |
| 1305 | c.update("56789"); | | |
| 1306 | try testing.expectEqual(crc_32_iso_hdlc.check, c.final()); | | |
| 1307 | } | | |
| 1308 | | | |
| 1309 | const crc_32_jamcrc: Algorithm(u32) = .{ .poly = 0x04c11db7, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0x00000000, .check = 0x340bc6d9, .residue = 0x00000000 }; | | |
| 1310 | | | |
| 1311 | pub const Crc32Jamcrc = Crc(u32, crc_32_jamcrc); | | |
| 1312 | | | |
| 1313 | test "CRC-32/JAMCRC" { | | |
| 1314 | try testing.expectEqual(crc_32_jamcrc.check, Crc32Jamcrc.hash("123456789")); | | |
| 1315 | | | |
| 1316 | var c = Crc32Jamcrc.init(); | | |
| 1317 | c.update("1234"); | | |
| 1318 | c.update("56789"); | | |
| 1319 | try testing.expectEqual(crc_32_jamcrc.check, c.final()); | | |
| 1320 | } | | |
| 1321 | | | |
| 1322 | const crc_32_mef: Algorithm(u32) = .{ .poly = 0x741b8cd7, .init = 0xffffffff, .refin = true, .refout = true, .xorout = 0x00000000, .check = 0xd2c22f51, .residue = 0x00000000 }; | | |
| 1323 | | | |
| 1324 | pub const Crc32Mef = Crc(u32, crc_32_mef); | | |
| 1325 | | | |
| 1326 | test "CRC-32/MEF" { | | |
| 1327 | try testing.expectEqual(crc_32_mef.check, Crc32Mef.hash("123456789")); | | |
| 1328 | | | |
| 1329 | var c = Crc32Mef.init(); | | |
| 1330 | c.update("1234"); | | |
| 1331 | c.update("56789"); | | |
| 1332 | try testing.expectEqual(crc_32_mef.check, c.final()); | | |
| 1333 | } | | |
| 1334 | | | |
| 1335 | const crc_32_mpeg_2: Algorithm(u32) = .{ .poly = 0x04c11db7, .init = 0xffffffff, .refin = false, .refout = false, .xorout = 0x00000000, .check = 0x0376e6e7, .residue = 0x00000000 }; | | |
| 1336 | | | |
| 1337 | pub const Crc32Mpeg2 = Crc(u32, crc_32_mpeg_2); | | |
| 1338 | | | |
| 1339 | test "CRC-32/MPEG-2" { | | |
| 1340 | try testing.expectEqual(crc_32_mpeg_2.check, Crc32Mpeg2.hash("123456789")); | | |
| 1341 | | | |
| 1342 | var c = Crc32Mpeg2.init(); | | |
| 1343 | c.update("1234"); | | |
| 1344 | c.update("56789"); | | |
| 1345 | try testing.expectEqual(crc_32_mpeg_2.check, c.final()); | | |
| 1346 | } | | |
| 1347 | | | |
| 1348 | const crc_32_xfer: Algorithm(u32) = .{ .poly = 0x000000af, .init = 0x00000000, .refin = false, .refout = false, .xorout = 0x00000000, .check = 0xbd0be338, .residue = 0x00000000 }; | | |
| 1349 | | | |
| 1350 | pub const Crc32Xfer = Crc(u32, crc_32_xfer); | | |
| 1351 | | | |
| 1352 | test "CRC-32/XFER" { | | |
| 1353 | try testing.expectEqual(crc_32_xfer.check, Crc32Xfer.hash("123456789")); | | |
| 1354 | | | |
| 1355 | var c = Crc32Xfer.init(); | | |
| 1356 | c.update("1234"); | | |
| 1357 | c.update("56789"); | | |
| 1358 | try testing.expectEqual(crc_32_xfer.check, c.final()); | | |
| 1359 | } | | |
| 1360 | | | |
| 1361 | const crc_40_gsm: Algorithm(u40) = .{ .poly = 0x0004820009, .init = 0x0000000000, .refin = false, .refout = false, .xorout = 0xffffffffff, .check = 0xd4164fc646, .residue = 0xc4ff8071ff }; | | |
| 1362 | | | |
| 1363 | pub const Crc40Gsm = Crc(u40, crc_40_gsm); | | |
| 1364 | | | |
| 1365 | test "CRC-40/GSM" { | | |
| 1366 | try testing.expectEqual(crc_40_gsm.check, Crc40Gsm.hash("123456789")); | | |
| 1367 | | | |
| 1368 | var c = Crc40Gsm.init(); | | |
| 1369 | c.update("1234"); | | |
| 1370 | c.update("56789"); | | |
| 1371 | try testing.expectEqual(crc_40_gsm.check, c.final()); | | |
| 1372 | } | | |
| 1373 | | | |
| 1374 | const crc_64_ecma_182: Algorithm(u64) = .{ .poly = 0x42f0e1eba9ea3693, .init = 0x0000000000000000, .refin = false, .refout = false, .xorout = 0x0000000000000000, .check = 0x6c40df5f0b497347, .residue = 0x0000000000000000 }; | | |
| 1375 | | | |
| 1376 | pub const Crc64Ecma182 = Crc(u64, crc_64_ecma_182); | | |
| 1377 | | | |
| 1378 | test "CRC-64/ECMA-182" { | | |
| 1379 | try testing.expectEqual(crc_64_ecma_182.check, Crc64Ecma182.hash("123456789")); | | |
| 1380 | | | |
| 1381 | var c = Crc64Ecma182.init(); | | |
| 1382 | c.update("1234"); | | |
| 1383 | c.update("56789"); | | |
| 1384 | try testing.expectEqual(crc_64_ecma_182.check, c.final()); | | |
| 1385 | } | | |
| 1386 | | | |
| 1387 | const crc_64_go_iso: Algorithm(u64) = .{ .poly = 0x000000000000001b, .init = 0xffffffffffffffff, .refin = true, .refout = true, .xorout = 0xffffffffffffffff, .check = 0xb90956c775a41001, .residue = 0x5300000000000000 }; | | |
| 1388 | | | |
| 1389 | pub const Crc64GoIso = Crc(u64, crc_64_go_iso); | | |
| 1390 | | | |
| 1391 | test "CRC-64/GO-ISO" { | | |
| 1392 | try testing.expectEqual(crc_64_go_iso.check, Crc64GoIso.hash("123456789")); | | |
| 1393 | | | |
| 1394 | var c = Crc64GoIso.init(); | | |
| 1395 | c.update("1234"); | | |
| 1396 | c.update("56789"); | | |
| 1397 | try testing.expectEqual(crc_64_go_iso.check, c.final()); | | |
| 1398 | } | | |
| 1399 | | | |
| 1400 | const crc_64_ms: Algorithm(u64) = .{ .poly = 0x259c84cba6426349, .init = 0xffffffffffffffff, .refin = true, .refout = true, .xorout = 0x0000000000000000, .check = 0x75d4b74f024eceea, .residue = 0x0000000000000000 }; | | |
| 1401 | | | |
| 1402 | pub const Crc64Ms = Crc(u64, crc_64_ms); | | |
| 1403 | | | |
| 1404 | test "CRC-64/MS" { | | |
| 1405 | try testing.expectEqual(crc_64_ms.check, Crc64Ms.hash("123456789")); | | |
| 1406 | | | |
| 1407 | var c = Crc64Ms.init(); | | |
| 1408 | c.update("1234"); | | |
| 1409 | c.update("56789"); | | |
| 1410 | try testing.expectEqual(crc_64_ms.check, c.final()); | | |
| 1411 | } | | |
| 1412 | | | |
| 1413 | const crc_64_redis: Algorithm(u64) = .{ .poly = 0xad93d23594c935a9, .init = 0x0000000000000000, .refin = true, .refout = true, .xorout = 0x0000000000000000, .check = 0xe9c6d914c4b8d9ca, .residue = 0x0000000000000000 }; | | |
| 1414 | | | |
| 1415 | pub const Crc64Redis = Crc(u64, crc_64_redis); | | |
| 1416 | | | |
| 1417 | test "CRC-64/REDIS" { | | |
| 1418 | try testing.expectEqual(crc_64_redis.check, Crc64Redis.hash("123456789")); | | |
| 1419 | | | |
| 1420 | var c = Crc64Redis.init(); | | |
| 1421 | c.update("1234"); | | |
| 1422 | c.update("56789"); | | |
| 1423 | try testing.expectEqual(crc_64_redis.check, c.final()); | | |
| 1424 | } | | |
| 1425 | | | |
| 1426 | const crc_64_we: Algorithm(u64) = .{ .poly = 0x42f0e1eba9ea3693, .init = 0xffffffffffffffff, .refin = false, .refout = false, .xorout = 0xffffffffffffffff, .check = 0x62ec59e3f1a4f00a, .residue = 0xfcacbebd5931a992 }; | | |
| 1427 | | | |
| 1428 | pub const Crc64We = Crc(u64, crc_64_we); | | |
| 1429 | | | |
| 1430 | test "CRC-64/WE" { | | |
| 1431 | try testing.expectEqual(crc_64_we.check, Crc64We.hash("123456789")); | | |
| 1432 | | | |
| 1433 | var c = Crc64We.init(); | | |
| 1434 | c.update("1234"); | | |
| 1435 | c.update("56789"); | | |
| 1436 | try testing.expectEqual(crc_64_we.check, c.final()); | | |
| 1437 | } | | |
| 1438 | | | |
| 1439 | const crc_64_xz: Algorithm(u64) = .{ .poly = 0x42f0e1eba9ea3693, .init = 0xffffffffffffffff, .refin = true, .refout = true, .xorout = 0xffffffffffffffff, .check = 0x995dc9bbdf1939fa, .residue = 0x49958c9abd7d353f }; | | |
| 1440 | | | |
| 1441 | pub const Crc64Xz = Crc(u64, crc_64_xz); | | |
| 1442 | | | |
| 1443 | test "CRC-64/XZ" { | | |
| 1444 | try testing.expectEqual(crc_64_xz.check, Crc64Xz.hash("123456789")); | | |
| 1445 | | | |
| 1446 | var c = Crc64Xz.init(); | | |
| 1447 | c.update("1234"); | | |
| 1448 | c.update("56789"); | | |
| 1449 | try testing.expectEqual(crc_64_xz.check, c.final()); | | |
| 1450 | } | | |
| 1451 | | | |
| 1452 | const crc_82_darc: Algorithm(u82) = .{ .poly = 0x0308c0111011401440411, .init = 0x000000000000000000000, .refin = true, .refout = true, .xorout = 0x000000000000000000000, .check = 0x09ea83f625023801fd612, .residue = 0x000000000000000000000 }; | | |
| 1453 | | | |
| 1454 | pub const Crc82Darc = Crc(u82, crc_82_darc); | | |
| 1455 | | | |
| 1456 | test "CRC-82/DARC" { | | |
| 1457 | try testing.expectEqual(crc_82_darc.check, Crc82Darc.hash("123456789")); | | |
| 1458 | | | |
| 1459 | var c = Crc82Darc.init(); | | |
| 1460 | c.update("1234"); | | |
| 1461 | c.update("56789"); | | |
| 1462 | try testing.expectEqual(crc_82_darc.check, c.final()); | | |
| 1463 | } | | |