im trying to code a 4 digit password cracker
Hey! im new to coding i watched a 4 hour course and tried to code my first project but i dont know what to do now.
56 Replies
Ask a question, and we can answer
Haha, my password is 0000 - you can't crack me!
ahahahahahh
how do i connect the index to the password variebel
You probably want to convert the number to a string that is padded with zeroes if it's less than 4 digits and then use that to compare with the input.
how do i do that?
How to: Pad a Number with Leading Zeros
Learn to pad a number with leading zeros. Add leading zeros to integers or numeric values to a specific total length or a specific number of leading zeros.
but the password is already a string
Yes, but
index
is notso should i change it to a string?
Optionally you could convert the string to an integer value. You should first validate it is actually four characters long in either case.
Using strings seems better to me because you can choose to try non-numeric inputs later with less changes to the code.
Like if you wanted to allow four letters instead of digits.
i made a code that writes down every number from 1 to 9999 and another one where it asks you to enter a password how to i connect them togehter
ill start with the basics first and maybe improve it thanks for the idea: )
Do you know how things like if statements work?
yes
Well, you probably want to use one.
okey ill try to
should it be like if(password = index)
{
}
somthing
mine's
abcE
. take that, hackers ;pSomething like that (note that in C# it's two equal signs to test for equality)
i made this so far
but its not working for some reason
Define 'modern'
SQL is an example of a language you might use regularly that uses a single equal sign
You're testing 9998 against 5432 for equality. It won't pass
ahaaaa i see it now
but how do i make it work
Take a stab at it
what do you mean?
PowerShell uses
-eq
🙂JS
That's not true
Ah, the triple equals
=== is only for type equality
But == will also work tho
I mean that I think you can figure it out
==
is a code smell, because of that.
[] == false
-> true
but [] === false
-> falseSet few breakpoints in your code and step through them. This ist the best way to understand the code you wrote. But maybe lower the loop^^
Anyway. TypeScript > Javascript. TypeScript makes frontend so adorable
ive been trying to for the past 2 days hahah but my brain isnt suited for thesse kinda stuff
ill try that thanks for the advice
*9999 actually, it's <=
It just takes practice.
i watched a lot of toturials
and ive been taking a coding class forthe past 3 weeks
Oh right. Missed it!
The issue here is a logic issue not a technical language issue.
Hint: should you be testing the value outside the loop? Or inside the loop?
Maybe a better approach would be to generate a random string as the secret code instead of a loop?
Stepping through the code in a debugger would definitely help. Or do what I usually do and add some print statements (Console.WriteLine) to spit out the state of your program while it's executing to check what the variables are set to at different points of execution.
Glorious CMake uses “EQUALS”
Because why would the build system designed for c and c++ be anything like c-style?!
Please I need to know
this is fascinating, i would love to know which one would be more efficient in the long run, random attack or brute force incremental
They're both useless for non-trivial search spaces.
thanks for sharing!
I'm not in the green
what do
(not on table for reference)
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Change your password 🙂
Yeah I meant some of my passwords are 32 chars so not on the table so not on the green
slightly facetious
32 chars...nice
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
That...is a correct statement but it's not going to let you brute force non-trivial passwords any faster...
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
That's off-topic!
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
User bammed successfully.