Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Simple program to find out the speed of making sha256 hashes in OpenOS (OpenComputers Minecraft mod's OS)
- using Tier 3 Data card and IgorTimofeev's SHA-256 library (https://raw.githubusercontent.com/IgorTimofeev/MineOS/master/Libraries/SHA-256.lua)
- My results are 0.47 and 3.9 for Data Card and Lib, respectively
- P.S. Sorry for bad lua code, I'm new to this
- --]]
- s = require('SHA-256')
- component = require('component')
- function AddZeroes(x, n)
- local p = tostring(x)
- while string.len(p) < n do
- p = "0" .. p
- end
- return p
- end
- function GetLastI(n)
- local p = ""
- for i = 1, n do
- p = p .. "9"
- end
- local x = tonumber(p)
- return x
- end
- function string.tohex(str)
- return (str:gsub('.', function (c)
- return string.format('%02X', string.byte(c))
- end))
- end
- data = component.data
- local x = os.clock()
- for a=1, 3 do
- for b=0, GetLastI(a) do
- p = AddZeroes(b,a)
- d = p .. ":" .. string.lower(string.tohex(data.sha256(p)))
- os.sleep(0)
- end
- end
- print("Using datacard: " .. os.clock() - x)
- local x = os.clock()
- for a=1, 3 do
- for b=0, GetLastI(a) do
- p = AddZeroes(b,a)
- d = p .. ":" .. s.hash(p)
- os.sleep(0)
- end
- end
- print("Using library: " .. os.clock() - x)
Advertisement
Add Comment
Please, Sign In to add comment