Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Software engineered and maintained by Coronaxe,
- please provide original author name when
- altering or redistributing this software!
- Thank you!
- ]]--
- if not _G.strman then
- error("Stringmanager could not be loaded!")
- end
- CryptX = {}
- function CryptX:craft( password )
- local crypt = {}
- setmetatable( crypt, self )
- self.__index = self
- if password then
- crypt:initialize( password )
- end
- return crypt
- end
- function CryptX:initialize( password )
- self.password = password
- self.randomlength = #password
- self.randomseed = strman.ArrToStr(strman.StrToByteArr( password )) / strman.StrToNumber( password )
- end
- function CryptX:encrypt( str )
- local tEncr = {}
- math.randomseed(self.randomseed)
- for i = 1, #str do
- table.insert(tEncr, str:byte(i,i) * math.random(1,self.randomlength))
- end
- return tEncr
- end
- function CryptX:decrypt( tEncr )
- local str = ""
- math.randomseed(self.randomseed)
- for i = 1, #tEncr do
- str = str .. string.char(tEncr[i] / math.random(1,self.randomlength))
- end
- return str
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement