]> git.zerfleddert.de Git - proxmark3-svn/blame - client/scripts/e.lua
CHG: minor layout and call fixes to e.lua (the test script for hooking up reveng1.30)
[proxmark3-svn] / client / scripts / e.lua
CommitLineData
60e86577 1local getopt = require('getopt')
2local utils = require('utils')
3
d3521467 4example = "script calculates many different checksums (CRC) over the provided hex input"
60e86577 5author = "Iceman"
6desc =
7[[
d3521467 8This script calculates many checksums (CRC) over the provided hex input.
60e86577 9
10Arguments:
11 -b data in hex
d3521467 12 -w bitwidth of the CRC family of algorithm. <optional> defaults to all known CRC presets.
60e86577 13Examples :
14 script run e -b 010203040506070809
15 script run e -b 010203040506070809 -w 16
16]]
17
18---
19-- A debug printout-function
20function dbg(args)
21 if DEBUG then
22 print("###", args)
23 end
24end
25---
26-- This is only meant to be used when errors occur
27function oops(err)
28 print("ERROR: ",err)
29 return nil,err
30end
31---
32-- Usage help
33function help()
34 print(desc)
35 print("Example usage")
36 print(example)
37end
38---
39-- The main entry point
40function main(args)
41
42 local data = '01020304'
43 local width = 0
44
45 -- Read the parameters
46 for o, a in getopt.getopt(args, 'hb:w:') do
47 if o == "h" then return help() end
d3521467 48 if o == "b" then data = a end
60e86577 49 if o == "w" then width = a end
50 end
51
d3521467 52 print( string.rep('-',60) )
53 print('Bit width of CRC | '..width)
54 print('Bytes | '..data)
60e86577 55 print('')
d3521467 56 print( ('%-20s| %-16s| %s'):format('Model','CRC', 'CRC reverse'))
57 print( string.rep('-',60) )
60e86577 58 local lists = core.reveng_models(width)
59 for _,i in pairs(lists) do
d3521467 60 local one = core.reveng_runmodel(i, data, false, 0)
61 local two = core.reveng_runmodel(i, data, true, 0)
62 print( ('%-20s| %-16s| %s'):format(i, one, two) )
60e86577 63 end
60e86577 64end
65
66main(args)
Impressum, Datenschutz