I'm taking the cs50x intro to comp sci course and one of the exercises is to decrypt a password that was encrypted using the crypt(3) function.
They've simplified the requirements by setting the hypothetical that the password can only be 5 characters long and every character will be an uppercase or lowercase letter.
I've hit a roadblock with encrypting and comparing and am unsure how to move forward.
Summary below.
I've made it as far as cycling through all possible variations of A-Z and a-z for A, AA, AAA, AAAA, and AAAAA.
And I can compare that to user input from argv.
Now I'm trying to have argv be a hash and compare that to the hash of ( possible password from above)
Where I'm struggling -->
How I imagine the code should work
- receive argv[1] and identify salt.
- generate password
- hash password with crypt()
- compare password-hash vs argv[1]
- if not a match, generate new password and repeat until match.
What's not working -->
storing the password hash for comparison and updating the password hash with new hash after manipulation.
What I think I understand -->
- The hash is stored as a string literal.
- You can't update string literals.
- I need to assign a variable to store the hash in order to compare it to argv.
What am I missing? What should I read up on to move forward?
thanks in advance!