1 local getopt = require('getopt')
2 local utils = require('utils')
4 example = "script calculates many checksums (CRC) over the provided hex input"
8 This script calculates many checksums (CRS) over the provided hex input.
12 -w width of the CRC algorithm. <optional> defaults to all known CRC presets.
14 script run e -b 010203040506070809
15 script run e -b 010203040506070809 -w 16
19 -- A debug printout-function
26 -- This is only meant to be used when errors occur
35 print("Example usage")
39 -- The main entry point
42 local data = '01020304'
45 -- Read the parameters
46 for o, a in getopt.getopt(args, 'hb:w:') do
47 if o == "h" then return help() end
48 if o == "b" then data = utils.ConvertHexToa end
49 if o == "w" then width = a end
52 print('Width of CRC: '..width..' bytes: '..data)
54 print('Model','CRC', 'CRC_Reverse')
56 local lists = core.reveng_models(width)
57 for _,i in pairs(lists) do
58 local one = core.reveng_runmodel(i, data, 0,0)
59 local two = core.reveng_runmodel(i, data, 1,0)