Skip to content

Instantly share code, notes, and snippets.

View perara's full-sized avatar
🎯
Focusing

Per-Arne Andersen perara

🎯
Focusing
View GitHub Profile
@perara
perara / rle.lua
Created October 29, 2020 20:40 — forked from Yonaba/rle.lua
Run-Length Encoding Algorithm
-- RLE Encryption Algorithm Implementation
-- Used for data compression
-- Assuming original file is 'test.txt'
local file = io.open("test.txt","rb")
local Ssize = file:seek("end")
file:seek("set",0)
--RLEncodes a single string
function encode(std,flag)
@perara
perara / rsa-crypt.lua
Created October 29, 2020 20:37 — forked from 1lann/rsa-crypt.lua
RSA encryption and decryption library in pure Lua for ComputerCraft
--
-- RSA Encryption/Decryption Library
-- By 1lann
--
-- Refer to license: http://pastebin.com/9gWSyqQt
--
-- See gists comment at the bottom of the page for FAQ and updates!
--
--
local function _W(f) local e=setmetatable({}, {__index = _ENV or getfenv()}) if setfenv then setfenv(f, e) end return f(e) or e end
local bit=_W(function(_ENV, ...)
--[[
This bit API is designed to cope with unsigned integers instead of normal integers
To do this we add checks for overflows: (x > 2^31 ? x - 2 ^ 32 : x)
These are written in long form because no constant folding.
]]
local floor = math.floor