Introduction, Usage & Content
Hello,
This is more of something I wanted to share than a tutorial, some may already know the logic but this something I want to show the beginner scripters and make a tutorial to make combination cracking code. It’s actually pretty fun once you get involved into alphabets and numbers but for this tutorial, I will only be doing numbers.
DISCLAIMER: THIS DOES NOT SUPPORT ANY KIND OF “PASSWORD CRACKING.” IT IS NOT CODE EFFICIENT EITHER, THIS REQUIRES AN ENDLESS AMOUNT OF CODE OUTPUT SPACE [FOR SOME COMBINATIONS].
-
It is highly unlikely that this code might crack every number as the program keeps guessing and guessing till it gets the correct match (that’s pretty much what all code crackers do unless you know something about the code). I did try it on online lua compilers but had limited code output, I believe roblox also has a limited code output.
-
Why am I posting this if you require a lot of code output? When I tested the code with some preset numbers, it did work and I wanted to make a tutorial to show how you can code different types of computer algorithms to work wonders for you.
If you’re an advanced scripter, you might find it boring.
Tutorial
Okay so, first create two tables. One table called numbers
that have the numbers from 0-9 and another table called trash
which is empty. The trash
table will be used to increase code efficiency and not test the same values again if in case they do repeat (that possibility is 1 in 10,000!)
local numbers = {0,1,2,3,4,5,6,7,8,9}
local trash = {}
Now that we made the tables, let’s go define a function that will do all the logic for us. So we’re going to select random numbers from the numbers
table and check if it is repeated, if it is repeated, we’re going to select another set of random indexes. After that we will concatenate the values from the given indexes.
local numbers = {0,1,2,3,4,5,6,7,8,9}
local trash = {}
function generate()
local index = math.random(1, #numbers)
local index2 = math.random(1, #numbers)
local index3 = math.random(1, #numbers)
local index4 = math.random(1, #numbers)
-- Seems rather disastrous, I didn't think of any other way :shrug:
local combination = numbers[index]..numbers[index2]..numbers[index3]..numbers[index4]
-- We're going to loop through the trash table to avoid the same value, although you really don't need to do this. The possibility of getting the same number again is 1 out of 10,000 (if you're using 4 digits).
for i, v in pairs(trash) do
if tostring(v) == tostring(combination) then
end
end
end
We just created our combination!
Now we do redo
the same thing for the trash folder. And you will see me use local index
again but it does not matter since we’re doing this through a local scope.
local numbers = {0,1,2,3,4,5,6,7,8,9}
local trash = {}
function generate()
local index = math.random(1, #numbers)
local index2 = math.random(1, #numbers)
local index3 = math.random(1, #numbers)
local index4 = math.random(1, #numbers)
-- Seems rather disastrous, I didn't think of any other way :shrug:
local combination = numbers[index]..numbers[index2]..numbers[index3]..numbers[index4]
-- We're going to loop through the trash table to avoid the same value, although you really don't need to do this. The possibility of getting the same number again is 1 out of 10,000 (if you're dealing with 4 digits).
for i, v in pairs(trash) do
if tostring(v) == tostring(combination) then
local index = math.random(1, #numbers)
local index2 = math.random(1, #numbers)
local index3 = math.random(1, #numbers)
local index4 = math.random(1, #numbers)
-- What we're also going to do is add the combination to the trash folder to define values we do not want which the one we used.
table.insert(trash, combination) -- Just skip the second parameter.
return combination
end
end
end
Since we set the code to return a new number if the combination already existed, now we need to make the one where it just returns the numbers. If you’re thinking about an else statement for the if tostring(v)...
, then that’s not really efficient since by returning the combination, the function won’t execute any code after. We can just leave that there and continue after.
local numbers = {0,1,2,3,4,5,6,7,8,9}
local trash = {}
function generate()
local index = math.random(1, #numbers)
local index2 = math.random(1, #numbers)
local index3 = math.random(1, #numbers)
local index4 = math.random(1, #numbers)
-- Seems rather disastrous, I didn't think of any other way :shrug:
local combination = numbers[index]..numbers[index2]..numbers[index3]..numbers[index4]
-- We're going to loop through the trash table to avoid the same value, although you really don't need to do this. The possibility of getting the same number again is 1 out of 10,000 (if you're dealing with 4 digits).
for i, v in pairs(trash) do
if tostring(v) == tostring(combination) then
local index = math.random(1, #numbers)
local index2 = math.random(1, #numbers)
local index3 = math.random(1, #numbers)
local index4 = math.random(1, #numbers)
-- What we're also going to do is add the combination to the trash folder to define values we do not want which the one we used.
table.insert(trash, combination) -- Just skip the second parameter.
return combination
end
end
table.insert(trash, combination)
-- We are inserting the combination so that we don't use it again.
return combination
end
With that, we finished our function.
Now all there is to do is the process to keep guessing. We can do that through a while loop, we keep guessing and break the loop once we get our value. You can add this to the end of your code-
local key
while wait(.1) do
key = generate()
if tostring(key) == '5034' then
print('Cracked!')
break
end
print(key)
end
And now we’re done!
You could define the key inside the loop but I just initialized it outside to approach it through a global scope just in case we may need it for future encounters.
Tips & Pointers
-
You might be tempted to do
local key = generate()
instead of initializing it at the start but doing so will get you nowhere sometimes. Remember that we do not want to use used combinations and we’re filtering out used ones before even they can reach the loop. So if your combination got cracked in the first try, before it entered the loop, you’re never going to get the number back since it’s in the trash table. -
The possibility of cracking a 4 digit code is 1 in 10,000. If you create 1 combination per millisecond, you can get the combination in 1000 seconds. That’s nearly 17 minutes if I round it to the nearest whole number.
-
You might be lucky and get the combination before your computer runs out of memory!
Finally
If you have any questions or problems, reply to this topic and ask them and I will answer them whenever I’m free.
Thank you for reading!