What's the best way to make a password generator and cracker. (I am not committing crimes)

I thought of brute force crackers earlier today, and I created a pretty simple password creator, and password cracker.

Please note this will strictly be used for playing around and it will not be used for illegal purposes. Any actions of your own with these scripts is your liability.

First, check out the scripts, fairly simple stuff.

local Strings = {"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 StringAmount = #Strings
local Password = ""
for i = 1,3 do 
	local NewNumber = math.random(1, StringAmount)
	local Variation = math.random(1,2)
	local LetterToAdd = Strings[NewNumber]
	if Variation == 1 then
		LetterToAdd = string.upper(LetterToAdd)
	end
	
	Password = Password .. LetterToAdd
end
print(Password)
script.Parent.Password.Value = Password

And the cracker script if you’d like to see it.

wait(5)
local Strings = {"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 PasswordToCheck = script.Parent.Password
local CurrentPassword = ""
local TimeStarted = os.time()
local Attempts = 0
repeat 
	Attempts += 1
	task.wait(0.0001)
	CurrentPassword = ""
	for i = 1,3 do 
		local NewNumber = math.random(1, #Strings)
		local Variation = math.random(1,2)
		local LetterToAdd = Strings[NewNumber]
		if Variation == 1 then
			LetterToAdd = string.upper(LetterToAdd)
		end

		CurrentPassword = CurrentPassword .. LetterToAdd
	end
	print(CurrentPassword)
until CurrentPassword == PasswordToCheck.Value
script["Flight Crash Alarm"]:Play() --I go AFK and do other stuff, so it alerts me once finished. Quite nice.
local TimeEnded = os.time()
local CurrentTime = tostring(TimeEnded-TimeStarted)
print("Password found in " .. CurrentTime .. " seconds!" .. " The password was " .. CurrentPassword .. "!")
print("Attempts = " .. tostring(Attempts))

I did 2 letters, and it took 37 seconds, I’m testing 3 right now…

It brought up a few questions.

What’s the best way to generate a password? Is there something more efficient?

Second, I’ve seen coding youtubers (with other coding languages, doing slightly different thing but also applicable), save their attempts, and not using that password again since they’ve already checked it.
But the problem with my script, is I have to generate it letter by letter. And the only way I’d be able to do it, would be by grabbing a whole password in one go, choosing out of all the possibilities. Do I generate all the possibilites, then pick, and then add them to the table of checked passwords.

5 Likes

Does anyone have any answers? I’m still looking, and I can’t find anything.

Can’t you just check and generate as you go? Making them random seems inefficient (idk tho)

I mean, maybe, but how would I do that? I mean, there’s no efficient way to check, because it still generates the password in the end, taking up my precious CPU/GPU performance (lol), even if I check it and it doesn’t compare it, I’m still gonna generate the same passwords. I don’t think there’s much of another way to create a whole password with my code knowing what’s wrong and what’s not.

1 Like