Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View operator-DD3's full-sized avatar
:octocat:
solo artist

Jacob Gardner operator-DD3

:octocat:
solo artist
  • banishing dirgist
View GitHub Profile
@operator-DD3
operator-DD3 / Set1-1.lua
Created August 26, 2015 15:04
[Lua] CryptoPals Cipher Challenge
local index_table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
function to_binary(integer)
local remaining = tonumber(integer)
local bin_bits = ''
for i = 7, 0, -1 do
local current_power = math.pow(2, i)
@operator-DD3
operator-DD3 / Set1-2.lua
Created August 26, 2015 15:07
[Lua] CryptoPals Cipher Challenge 1-2
local index_table = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
function to_binary(integer)
local remaining = tonumber(integer)
local bin_bits = ''
for i = 7, 0, -1 do
local current_power = math.pow(2, i)
@operator-DD3
operator-DD3 / matasano.lua
Created August 29, 2015 08:46
[Lua] CryptoPals 1st attempt
-- Matasano Crypto Challenge
--
-- Jacob Gardner 2014
-- Challenge 1 (Convert hex to base64)
test1 = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d"
real1 = "SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t"
@operator-DD3
operator-DD3 / string2table.lua
Created July 18, 2014 07:49
String to Table
local str = "text"
local t = {}
for i = 1, #str do
t[i] = str:sub(i, i)
end
@operator-DD3
operator-DD3 / tableRemDup.lua
Created July 18, 2014 08:17
Table Remove Duplicates
local test = {1,2,4,2,3,4,2,3,4,"A", "B", "A"}
local hash = {}
local res = {}
for _,v in ipairs(test) do
if (not hash[v]) then
res[#res+1] = v
hash[v] = true
end
end
@operator-DD3
operator-DD3 / execute.lua
Created July 20, 2014 08:40
Execute command
function os.capture(cmd, raw)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if raw then return s end
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
return s
end
@operator-DD3
operator-DD3 / date.lua
Created July 24, 2014 01:14
Lua Date Problem. These values, I thought, should be equal. 'a' is 6 hours behind 'b'.
local a = os.date('%c')
local b = os.date('!%a %b %d %H:%M:%S %Y')
print('Date: ' .. a)
print('UTC: ' .. b)
@operator-DD3
operator-DD3 / fs.lua
Created August 11, 2015 02:36
A fake operating system created in Lua.
FOS = {}
-- serialize functions
local function char(c) return ("\\%3d"):format(c:byte()) end
local function szstr(s) return ('("%s")'):format(s:gsub("[^ !#-~]", char)) end
local function szfun(f) return "loadstring"..szstr(string.dump(f)) end
function hex_dump(buf) for i=1,math.ceil(#buf/16) * 16 do if (i-1) % 16 == 0 then io.write(string.format('%08X ', i-1)) end io.write( i > #buf and ' ' or string.format('%02X ', buf:byte(i)) ) if i % 8 == 0 then io.write(' ') end if i % 16 == 0 then io.write( buf:sub(i-16+1, i):gsub('%c','.'), '\n' ) end end end
-- Root directory
FOS["/"] = {"bin", "home"}
@operator-DD3
operator-DD3 / stackVM.lua
Created August 11, 2015 03:04
A stack machine emulator created in Lua.
local txt="0 33 100 108 114 111 87 32 44 111 108 108 101 72 debug if outputascii fi"
io.write("Welcome to SuperStack!\nEnter your 'name':")
user = io.read()
io.write("\n" .. user .. "@superstack: ")
local txt = io.read()
--program=program.." "
txt=txt.." "
@operator-DD3
operator-DD3 / xsadb.lua
Last active August 29, 2015 14:27
[Lua] XSA Database v1.0
-- XSA DATABASE (XSADB)
-- Copyright 2015
-- XOUT SECURITY AGENCY (XSA)
function wrap(str, limit, indent, indent1) indent = indent or "" indent1 = indent1 or indent limit = limit or 72 local here = 1-#indent1 return indent1..str:gsub("(%s+)()(%S+)()", function(sp, st, word, fi) if fi-here > limit then here = st - #indent return "\n"..indent..word end end) end
function uuid()
my_uuid = ""
t = {[0] = '0', [1] = '1', [2] = '2', [3] = '3', [4] = '4', [5] = '5', [6] = '6', [7] = '7', [8] = '8', [9] = '9', [10] = 'a', [11] = 'b', [12] = 'c', [13] = 'd', [14] = 'e', [15] = 'f'}
for i = 1, 32 do