Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- if #args < 2 then
- print("USAGE: decryptor [key] [side]")
- end
- local key = tonumber(args[1])
- math.randomseed(os.time())
- local chars = {
- "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",
- " ",
- "_",
- "#",
- "@",
- "!",
- "*",
- "^",
- "1",
- "2",
- "3",
- "4",
- "5",
- "6",
- "7",
- "8",
- "9",
- "0",
- "+",
- "-",
- "~",
- "`",
- "%",
- "$",
- "{",
- "}",
- "\\",
- "/",
- ">",
- "<",
- ";",
- ":",
- }
- local function generateRandomChar(includeUpper)
- local char = chars[math.random(1,#chars)]
- if includeUpper then
- local doUpper = math.random(1,2)
- if doUpper == 2 then
- char = string.upper(char)
- end
- end
- return char
- end
- local function doDecrypt(side)
- local lines = {}
- local currentLine = ""
- local path = fs.combine(disk.getMountPath(side), "data")
- local handle = fs.open(path, "rb")
- while true do
- local byte = handle.read()
- if byte then
- byte = bit.bxor(byte, key)
- currentLine = currentLine..string.char(byte)
- if string.char(byte) == "\n" then
- table.insert(lines, currentLine)
- currentLine = ""
- end
- else
- break
- end
- end
- handle.close()
- return lines
- end
- local function lookCool(lines)
- for i,v in ipairs(lines) do
- local coolStr = ""
- for progress=1, 20 do
- for i=1, #v do
- coolStr = coolStr..generateRandomChar(true)
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Currently decrypting line "..i.."...")
- print("Line Progress: "..math.floor((progress/20)*100).."%")
- print("Total Progress: "..math.floor((i/#lines)*100).."%")
- print("Current Attempt:")
- print(coolStr)
- coolStr = ""
- os.sleep(0.5)
- end
- local handle = fs.open("decrypted.data", "a")
- handle.write(v)
- handle.close()
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Done!")
- print("Data written to \"decrypted.data\".")
- end
- lookCool(doDecrypt(args[2]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement