Created
June 2, 2022 12:16
-
-
Save ochaton/6ece0523c1915f0368fd26642a5a76c0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 fun = require 'fun' | |
local l337 = function(s) | |
return (s:lower():gsub('.', { | |
a = 'a', b = '8', c = 'c', d = 'd', e = 'e', f = 'f', | |
g = '6', h = '4', i = '9', j = '7', k = '0', l = '1', | |
m = '44', n = '11', o = '0', p = '17', q = '9', r = '12', | |
s = '5', t = '7', u = '4', v = '5', w = '22', x = '8', y = '7', z = '5', | |
})) | |
end | |
encode_uuid = function(str) | |
local word = l337(str:lower():gsub("[^a-z0-9]+", "")) | |
local shift = 1 | |
local r = {} | |
for _, len in fun.map(fun.length, uuid.str():split"-") do | |
local chunk = word:sub(shift, shift+len-1) | |
chunk = chunk..('0'):rep(len-#chunk) | |
table.insert(r, chunk) | |
shift = shift + len | |
end | |
return table.concat(r, '-') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment