-- Lua-hashings @89879fe79b6f3dc495c607494126ec9c3912b8e9 | /hashings/pbkdf2.lua | https://github.com/user-none/lua-hashings | License: MIT License | Minified using https://www.npmjs.com/package/luamin/v/1.0.4
-- Copyright (c) 2016 John Schember
-- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
local a=require("string")local b=require("nums.uintn").u32;local c=require("hashings.hmac")local d={}local function e(f,g)local h={}local i={}local j={}for k=1,#f do h[#h+1]=a.byte(f,k)end;for k=1,#g do i[#i+1]=a.byte(g,k)end;for k=1,#h do j[#j+1]=a.char(h[k]~i[k])end;return table.concat(j)end;local function l(m)local n={}for k=1,#m do n[k]=a.format("%02X",a.byte(m,k))end;return table.concat(n)end;function d:pbkdf2(o,p,q,r)local s;local t;s=c(o,p,q..b(1):asbytestring()):digest()t=s;for k=2,r do s=c(o,p,s):digest()t=e(t,s)end;return l(t)end;setmetatable(d,{__call=d.pbkdf2})return d
