Posted 19 August 2012 - 01:17 PM
Hi, im wondering is there a way to make a keygen in ComputerCraft, im fairly new to CC so if someone does know can you add notes so i can see what the code is doing, thanks in advance
Like if someone made a password door with theWhat is a keygen in this context?
function genKey(len)
s={}
for n=0, 127 do
s[n]=string.char(n)
end
function t01(len)
ret={}
for num=1, len do
ret[#ret+1]=0
end
return unpack(ret)
end
all={}
states={{t01(len)}}
sa=300
for n=1, table.maxn(s)^len do
if math.floor(n/sa)==n/sa then sleep(0) end
function set(s)
states[n]=states[#states]
states[n][s]=states[n][1]+1
if states[n][s]==128 then
states[n][s]=0
if s<len then
set(s+1)
end
end
end
set(1)
function charAll()
ret={}
for num=1, len do
ret[num]=string.char(states[n][num])
end
return table.concat(ret, "")
end
all[n]=charAll()
end
return all
end
is there a way to simplify that explanation xD, but thanks soo much for the code xDCode:function genKey(len) s={} for n=0, 127 do s[n]=string.char(n) end function t01(len) ret={} for num=1, len do ret[#ret+1]=0 end return unpack(ret) end all={} states={{t01(len)}} sa=300 for n=1, table.maxn(s)^len do if math.floor(n/sa)==n/sa then sleep(0) end function set(s) states[n]=states[#states] states[n][s]=states[n][1]+1 if states[n][s]==128 then states[n][s]=0 if s<len then set(s+1) end end end set(1) function charAll() ret={} for num=1, len do ret[num]=string.char(states[n][num]) end return table.concat(ret, "") end all[n]=charAll() end return all end
You can use this function (genKey), param 1 has to be the length of the password.
And no worry if its taking long to build the keys… The function is just working (if you want to know how much rounds the main for loop goes, just type in the lua shell math.pow(128, thenumberofthespaces))
How it works:
every space is 1 number. It increases the number each round +1. If the number==128 then it sets the number to 0, and the next number in the states table +1.