Alyssa

hash

Dec 21st, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.66 KB | None | 0 0
  1. --[[
  2. Written by valithor
  3. http://www.computercraft.info/forums2/index.php?/topic/24527-small-hashingencryption-api/page__hl__encrypt__fromsearch__1
  4. ]]--
  5. function hash(msg,salt,bool)
  6.   if not bool then
  7.         for i = 1, 10 do
  8.           msg = hash(msg,salt or "",true)
  9.         end
  10.   end
  11.   local num = ""
  12.   local salt = salt ~= nil and salt..msg or msg
  13.   for i = 1, #salt do
  14.         local let = salt:sub(i,i):byte()
  15.         num = let <= 9  and num.."99"..let or let<=99 and num.."9"..let or num..let
  16.   end
  17.   math.randomseed(tonumber(num))
  18.   local hashed = ""
  19.   for i = 1, 32 do
  20.         hashed = hashed..string.char(math.random(32,127))
  21.   end
  22.   return hashed
  23. end
Advertisement
Add Comment
Please, Sign In to add comment