Well first of all.. "Hashes" are algorithm which CANNOT be "de-hashed" as you might think off..
What you're looking at is Encrypt/Decryption algorithms.
My forms for decrypt/encrypt is the following:
– It requires a string to be encrypted, and some password, so you only can reuse it…
Spoiler
local ValidChars = {
"!","\"","#","$","%","&","'","(",")","*","+",",","-",".","/","0","1","2","3",
"4","5","6","7","8","9",":",";","<","=",">","?","@","A","B","C","D","E","F","G",
"H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","[",
"\\","]","^","_","`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
"p","q","r","s","t","u","v","w","x","y","z","{","|","}","~";
} -- well yeah... just a table with the valid chars which can be encrypted.
local CharToCode = {}
local CodeToChar = {}
for _, c in pairs(ValidChars) do
local code = #CodeToChar+1
CharToCode[c] = code
CodeToChar[code] = c
end
string.encrypt = function(msg, key) -- encrypt
math.randomseed(key)
local out = ""
for i = 1,#msg do
local c = msg:sub(i,i)
local code = CharToCode[c]
code = code + math.random(0,#ValidChars)
if code > #ValidChars then
code = code - #ValidChars
end
out = out..CodeToChar[code]
end
return out
end
string.decrypt = function(msg, key) --decrypt
math.randomseed(key)
local out = ""
for i = 1,#msg do
local c = msg:sub(i,i)
local code = CharToCode[c]
code = code - math.random(0,#ValidChars)
if code < 1 then
code = #ValidChars + code
end
out = out..CodeToChar[code]
end
return out
end
Usage?:
– sender computer
os.run({},"myprogramname") -- if you used my code as another program
-- if not, then delete this^
local side = "right"
local yourkey = 1234
print("input a string to encrypt:")
local str=string.encrypt(read(),yourkey)
print("Encrypted string:\n"..str)
rednet.open(side)
rednet.broadcast(str)
–receiver computer
os.run({},"myprogramname")
local side = "right"
local yourkey = 1234
rednet.open(side)
while true do
local id, msg, dist=rednet.receive()
local decryptedString = string.decrypt(msg,yourkey)
print("Received string: "..msg)
print("Decrypted string as: "..decryptedString)
end
If you want more information just ask… else you might be able to find tutorials in the "tutorials" section..(else: Use Google)