C
C#3y ago
TOLOXI

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
Monsieur Wholesome
Ask a question, and we can answer
mtreit
mtreit3y ago
Haha, my password is 0000 - you can't crack me!
TOLOXI
TOLOXIOP3y ago
ahahahahahh how do i connect the index to the password variebel
mtreit
mtreit3y ago
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.
TOLOXI
TOLOXIOP3y ago
how do i do that?
mtreit
mtreit3y ago
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.
TOLOXI
TOLOXIOP3y ago
but the password is already a string
mtreit
mtreit3y ago
Yes, but index is not
TOLOXI
TOLOXIOP3y ago
so should i change it to a string?
mtreit
mtreit3y ago
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.
TOLOXI
TOLOXIOP3y ago
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: )
mtreit
mtreit3y ago
Do you know how things like if statements work?
TOLOXI
TOLOXIOP3y ago
yes
mtreit
mtreit3y ago
Well, you probably want to use one.
TOLOXI
TOLOXIOP3y ago
okey ill try to should it be like if(password = index) { } somthing
Up
Up3y ago
mine's abcE. take that, hackers ;p
mtreit
mtreit3y ago
Something like that (note that in C# it's two equal signs to test for equality)
TOLOXI
TOLOXIOP3y ago
TOLOXI
TOLOXIOP3y ago
i made this so far but its not working for some reason
mtreit
mtreit3y ago
Define 'modern' SQL is an example of a language you might use regularly that uses a single equal sign
jmb
jmb3y ago
You're testing 9998 against 5432 for equality. It won't pass
TOLOXI
TOLOXIOP3y ago
ahaaaa i see it now but how do i make it work
mtreit
mtreit3y ago
Take a stab at it
TOLOXI
TOLOXIOP3y ago
what do you mean?
mtreit
mtreit3y ago
PowerShell uses -eq 🙂
Up
Up3y ago
JS
jmb
jmb3y ago
That's not true
mtreit
mtreit3y ago
Ah, the triple equals
jmb
jmb3y ago
=== is only for type equality But == will also work tho
mtreit
mtreit3y ago
I mean that I think you can figure it out
Up
Up3y ago
== is a code smell, because of that. [] == false -> true but [] === false -> false
jmb
jmb3y ago
Set 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
TOLOXI
TOLOXIOP3y ago
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
Up
Up3y ago
*9999 actually, it's <=
mtreit
mtreit3y ago
It just takes practice.
TOLOXI
TOLOXIOP3y ago
i watched a lot of toturials and ive been taking a coding class forthe past 3 weeks
jmb
jmb3y ago
Oh right. Missed it!
mtreit
mtreit3y ago
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?
jmb
jmb3y ago
Maybe a better approach would be to generate a random string as the secret code instead of a loop?
mtreit
mtreit3y ago
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.
wastingtime
wastingtime3y ago
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
Henkypenky
Henkypenky3y ago
this is fascinating, i would love to know which one would be more efficient in the long run, random attack or brute force incremental
mtreit
mtreit3y ago
They're both useless for non-trivial search spaces.
mtreit
mtreit3y ago
Henkypenky
Henkypenky3y ago
thanks for sharing!
wastingtime
wastingtime3y ago
I'm not in the green what do (not on table for reference)
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
mtreit
mtreit3y ago
Change your password 🙂
wastingtime
wastingtime3y ago
Yeah I meant some of my passwords are 32 chars so not on the table so not on the green slightly facetious
mtreit
mtreit3y ago
32 chars...nice
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
mtreit
mtreit3y ago
That...is a correct statement but it's not going to let you brute force non-trivial passwords any faster...
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Yawnder
Yawnder3y ago
That's off-topic!
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX3y ago
User bammed successfully.
Want results from more Discord servers?
Add your server