Skip to content

Instantly share code, notes, and snippets.

@robbat2
Last active December 5, 2020 06:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robbat2/8be892b20f8aef3e6f2bbf586f9e7181 to your computer and use it in GitHub Desktop.
Save robbat2/8be892b20f8aef3e6f2bbf586f9e7181 to your computer and use it in GitHub Desktop.
local crypto = require("crypto")
function filter_open(email, page)
buffer = ""
hexdigest = crypto.digest("md5", email:sub(2, -2):lower())
end
function filter_close()
html("<span class='gravatar'><img class='inline' src='//www.gravatar.com/avatar/" .. hexdigest .. "?s=13&amp;d=retro' /><img class='onhover' src='//www.gravatar.com/avatar/" .. hexdigest .. "?s=128&amp;d=retro' /></span>" .. buffer)
return 0
end
function filter_write(str)
buffer = buffer .. str
end
local openssl = require("openssl")
local digest = require("openssl.digest")
local function tohex(b)
local x = ""
for i = 1, #b do
x = x .. string.format("%.2x", string.byte(b, i))
end
return x
end
local function hexdigest(algo, input)
local hash = algo
local data = digest.new(hash)
local digest_output = data:final(input)
return tohex(digest_output)
end
function filter_open(email, page)
buffer = ""
hexdigest = crypto.digest("md5", email:sub(2, -2):lower())
hexdigest = hexdigest('md5', email:sub(2, -2):lower())
end
function filter_close()
html("<span class='gravatar'><img class='inline' src='//www.gravatar.com/avatar/" .. hexdigest .. "?s=13&amp;d=retro' /><img class='onhover' src='//www.gravatar.com/avatar/" .. hexdigest .. "?s=128&amp;d=retro' /></span>" .. buffer)
return 0
end
function filter_write(str)
buffer = buffer .. str
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment