Is there any way to create a sha256 hash inside my luup code? I need this to call a webservice that requires an SHA256 authentication string.
Maybe borrow this code: lua-users wiki: Secure Hash Algorithm
You can also use OpenSSL on the Vera:
function Hash(hsh)
local res
local f = io.popen("echo -n '" .. hsh .. "' | openssl dgst -binary | openssl base64")
if (f) then
res = f:lines()()
f:close()
end
return res
end
You may have to adjust the openssl arguments to get the hash function you want …
Or this [url=http://rosettacode.org/wiki/SHA-256#Lua]http://rosettacode.org/wiki/SHA-256#Lua[/url] ?
I do not thing Vera has the crypto LUA modules available.
My mistake… I do all my plugin development and daily use on non-Vera hardware (running openLuup) which makes it much easier to plug in this sort of thing.
The openssl seems like a smart move. I will give that a try.Thanks.
I thought the luasec library (https://github.com/brunoos/luasec/wiki) which seems to be included with Vera was a wrapper for OpenSSL?
You should be able to use this simply with
local ssl = require "ssl"
How, or whether, you can select SHA256, I don’t know.