]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/scripts/e.lua
Allow externalisation of PrintAndLog (#506)
[proxmark3-svn] / client / scripts / e.lua
index 4dd714901fe9a4e5c569211da9a6bd647ce5fc3b..a20b8e473a1a92f6c24a9a37bb35c9885aa7e887 100644 (file)
@@ -1,15 +1,15 @@
 local getopt = require('getopt')
 local utils = require('utils')
 
-example = "script calculates many checksums (CRC) over the provided hex input"
+example = "script calculates many different checksums (CRC) over the provided hex input"
 author = "Iceman"
 desc =
 [[
-This script calculates many checksums (CRS) over the provided hex input. 
+This script calculates many checksums (CRC) over the provided hex input. 
 
 Arguments:
        -b                              data in hex
-       -w                              width of the CRC algorithm. <optional> defaults to all known CRC presets.
+       -w                              bitwidth of the CRC family of algorithm. <optional> defaults to all known CRC presets.
 Examples : 
        script run e -b 010203040506070809
        script run e -b 010203040506070809 -w 16
@@ -39,31 +39,34 @@ end
 -- The main entry point
 function main(args)
 
-       local data = '01020304'
+       local data
        local width = 0
 
        -- Read the parameters
        for o, a in getopt.getopt(args, 'hb:w:') do
                if o == "h" then return help() end
-               if o == "b" then data = utils.ConvertHexToa end
+               if o == "b" then data = a end
                if o == "w" then width = a end
        end
 
-       print('Width of CRC: '..width..'  bytes: '..data)
-       print('')
-       print('Model','CRC', 'CRC_Reverse')
+       data = data or '01020304'
        
+       print( string.rep('-',60) )
+       print('Bit width of CRC | '..width)
+       print('Bytes            | '..data)
+       print('')
+       print( ('%-20s| %-16s| %s'):format('Model','CRC', 'CRC reverse'))
+       print( string.rep('-',60) )
        local lists = core.reveng_models(width)
        for _,i in pairs(lists) do
-               local one = core.reveng_runmodel(i, data, 0,0)
-               local two = core.reveng_runmodel(i, data, 1,0)
-               
-               print(i, one, two)
+               local a1 = core.reveng_runmodel(i, data, false, '0')
+               local a2 = core.reveng_runmodel(i, data, true, '0')
+               local a3 = core.reveng_runmodel(i, data, false, 'b')
+               local a4 = core.reveng_runmodel(i, data, false, 'B')
+               local a5 = core.reveng_runmodel(i, data, false, 'l')
+               local a6 = core.reveng_runmodel(i, data, false, 'L')            
+               print( ('%-20s| %-16s| %-16s| %-16s| %-16s| %-16s| %-16s'):format(i, a1:upper(), a2:upper(),a3:upper(),a4:upper(),a5:upper(),a6:upper() ) )
        end
-       
-       if 1 == 1 then
-        return
-       end 
 end
 
 main(args)
\ No newline at end of file
Impressum, Datenschutz