Last active
December 5, 2020 06:32
-
-
Save robbat2/8be892b20f8aef3e6f2bbf586f9e7181 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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&d=retro' /><img class='onhover' src='//www.gravatar.com/avatar/" .. hexdigest .. "?s=128&d=retro' /></span>" .. buffer) | |
return 0 | |
end | |
function filter_write(str) | |
buffer = buffer .. str | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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&d=retro' /><img class='onhover' src='//www.gravatar.com/avatar/" .. hexdigest .. "?s=128&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