From a242bc42e2a914d4cf9a8223563e2f6cce0f7feb Mon Sep 17 00:00:00 2001 From: itec78 Date: Sat, 29 Jul 2023 15:36:50 +0200 Subject: [PATCH] mac2banana --- bananalime.lua | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 bananalime.lua diff --git a/bananalime.lua b/bananalime.lua new file mode 100755 index 0000000..fe4cb9a --- /dev/null +++ b/bananalime.lua @@ -0,0 +1,42 @@ +#!/usr/bin/lua + +function mac2banana(mac) + v = tonumber(string.sub(table.concat(mac,""),-6),16) + minlength = 8 + + alphabets = {{"b","c","d","f","g","l","m","n","p","r","s","t","v","z"}, {"a","e","i","o","u"}}; + shiftalpha = 0 + alphaend = 0 + + numalpha = #alphabets + st = "" + length = 0 + idx = (numalpha - 1 + shiftalpha + alphaend) % numalpha + while (not (v == 0 and idx == (numalpha - 1 + shiftalpha) % numalpha and length >= minlength)) + do + al = alphabets[idx + 1] + r = v % #al + v = math.floor(v / #al) + st = al[r + 1] .. st + + idx = (idx + numalpha - 1) % numalpha; + length = length + 1 + end + + return st +end + + + +-- mac = {"4c","34","88","88","5e","e6"} +-- mac = {"50","7b","9d","38","a3","bc"} +mac = {"18","d6","c7","95","41","c3"} + +template = "Lime-%M4%M5%M6" +for i=1,6,1 do template = template:gsub("%%M"..i, mac[i]) end +print(template) + +local macbanana = mac2banana(mac) +template = "Lime-%B8" +for i=4,8,2 do template = template:gsub("%%B"..i, string.sub(macbanana, -i)) end +print(template)