4
votes
Accepted
pset2: Crack takes a lot of time
Answered by an instructor on reddit.
here:https://www.reddit.com/r/cs50/comments/9o3eg8/pset2_crack_is_taking_a_lot_of_time/
- 53
3
votes
Accepted
pset2 crack - values are equal but the program claims equality is false
You should use strcmp, not "==" when comparing two strings in c. The strcmp function, included in string.h takes in two parameters, your two strings, and outputs 0 if the strings are equal. If you ...
- 182
2
votes
Accepted
pset2 Crack - Looping through fgets
Let's take a look at the man page of strcat():
char *strcat(char *dest, const char *src);
The strcat() function appends the src string to the dest
string, overwriting the terminating null ...
- 7,366
2
votes
I solved crack, but have a shallow understanding of the techniques used
In C a string name is just a pointer to the actual string located somewhere
in memory ending with a NULL character. So when you use the "==" operator to
check it's equality you are basically ...
- 550
2
votes
Crack: Segfault on CS50 appliance/ IDE/ CS50.io but fine on my computer
Ok, I've found answer to c segmentation fault on tail recursion:
changing clang option -o from 0 to 3 fixes this problem as this enables better optimization:
clang -fsanitize=integer -fsanitize=...
- 31
2
votes
Crack: Segfault on CS50 appliance/ IDE/ CS50.io but fine on my computer
if(!offset) offset = 0; does nothing. 0 is the value of false, while anything different could be interpreted as true in many contexts (even if it does not equal true, which is 1).
With word[offset=='...
- 20.8k
2
votes
Accepted
pset2 crack - stelios only password I can't crack
Other than the exact letters that are in it, it's no different from the others. I'll give you the hint that the first letter is 'A' Maybe your algorithm is somehow skipping that?
- 18.5k
2
votes
Pset2 Crack: why are CS50's crypt hashes different from mine?
Maybe you are confusing two things. Those words on the left ("rob", "brian") are user names. The hashes are hashes of the associated passwords. That's a format you might find in the /etc/passwd file ...
- 20.8k
2
votes
Accepted
Pset2 can't crack stelios password
Did you let it run to completion or did you stop it while it was still running? This pset is notorious for running very long times for 5 letter passwords. Try running it overnight and see if it ...
- 66.7k
2
votes
PSet 2: Crack - Faster Methods?
I have used recursion, wrapped inside one loop for the number of digits. Which I think is the same approach mentioned by User20025. The recursion concept is that a 3 letter password is 1 letter plus a ...
- 21
1
vote
Accepted
PSet2 Crack: crypt() returning same hash
I'd say crypt works as expected, and is not the cause for your problem.
Passing z or z_val does the same thing, as arrays are passed as a pointer to their first element. Same goes for returning o or ...
- 20.8k
1
vote
Accepted
PSET 2 Crack: Getting salt from argv[1]
argv [1] is, in effect, a string, however the statement:
string salt[3];
It is incorrect. What are you really saying? Keep in mind that the variable of type string does not exist in c, it is a ...
- 5,201
1
vote
How to generate passwords in Crack Pset 2?
Yes, you can have password that are mixed case. I believe you already know how to join strings or individual chars together, for example from exercises where we learn to printf "Hello" + name together....
- 21
1
vote
Accepted
Question about Crack in PSET2
The salt must be saved together with the hash, so that we can reproduce the result. A password check function would hash a password using the same salt and compare the results. The salt here are the ...
- 20.8k
1
vote
Accepted
crack.c: No response 😒
I'd remove the space from the pool of valid password characters, and try again. Maybe you saw a less than 5 character password with some space character in front.
You don't have a break; after done = ...
- 20.8k
1
vote
Accepted
crack.c: UndefinedBehaviorSanitizer:DEADLYSIGNAL --SOLVED--
The UndefinedBehaviorSanitizer (aka UBSan) relates to execution-time bugs caused by various kinds of undefined programme behaviour. For instance,
Using misaligned or null pointer,
Signed integer ...
- 555
1
vote
Accepted
pset2 crack: Takes too long
Keep in mind that a "string" in C is simply a character array that is null terminated.
As such, your salt variable is not a string, nor is your temp variable in all cases.
As a consequence, when you ...
- 18.5k
1
vote
pset2 crack: Takes too long
This program takes a notoriously long time to run. It's also an exercise in making code more efficient. Also, at this point, you should start being able to answer questions on your own, like this one:
...
- 66.7k
1
vote
Accepted
CS50: Crack - 'incompatible pointer types' error
The crypt function needs a pointer to key, however you are passing a pointer to pointers, or an array of pointers, or word **, that is not the expected type
- 5,201
1
vote
Accepted
pset2 crack.c Random Characters Follow When Getting Salt
Where's the end of string marker \0?
printf will keep printing whatever follows in memory until it sees the EOS marker, even into other areas of memory.
If this answers your question, please click ...
- 66.7k
1
vote
Accepted
Crack missing two of ten hashes
char candidate[5] is a char array with 5 chars. It is not a 'string' which is what crypt needs. (a string is a char array that ends in a null char).
I'm actually surprised you are finding any ...
- 18.5k
1
vote
Accepted
Pset2 Crack - Including printf causes passwords I am generating to change
The problem was hiding somewhere else:
// Create pword w/ max of 5 chars
char pword[6];
pword[5] = '\0';
That means that the first 4 chars are whatever random garbage is in them when the char array ...
- 66.7k
1
vote
Accepted
Why this code cannot decrypt passwords which are more than two characters?
for (int k = 0; k < 0; k++)
This loop will never be entered, as initial value 0 is not <0
- 20.8k
1
vote
Accepted
Pset 2 Crack producing different hashes for same variables each time
char pw[5];
pw[0] = check[i];
crypt(pw, salt);
at this point, pw is not a string. A string is a char array terminating in the null char. You've set pw[0] to 'a' but the next 4 chars in pw are ...
- 18.5k
1
vote
Accepted
PSET2 (Crack) - Comparing 2 hashes with strcmp() always returns 0
When you read the man page for crypt, you maybe missed this:
The return value points to static data whose content is overwritten by each call.
Each time you call crypt, the static string that ...
- 18.5k
1
vote
Accepted
pset2 crack.c, competence question
The 'more comfortable' problems seem to be geared toward people who have at least a little prior experience in programming. The entire problem can be solved with arrays and loops (in under 100 lines ...
- 814
1
vote
Accepted
My crack.c code will compile, but fails to crack password (Brute force method) and takes approx. 4 minutes
It doesn't work: string1 == string2. Even if they are equal you won't get "true". You should compare them char by char. Happily, somebody has already coded special function available in string.h: ...
- 1,139
1
vote
Accepted
strcmp not evaluating as expected
It looks like strcmp() isn't being used as it should. ( I don't understand why the result of strcmp is being checked for > 1. )
The strcmp(s1, s2) function compares two strings, char by char and ...
- 66.7k
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
pset2-crack × 43pset2 × 29
crack × 24
crack.c × 12
cs50x × 5
crypt × 5
c × 3
hash × 2
caesar × 1
segmentation-fault × 1
appliance × 1
cs50x2017 × 1
pset2-caesar × 1
help × 1
segfault × 1
variables × 1
printf × 1
command-line-arguments × 1
bug × 1
while-loop × 1
fgets × 1
incompatibletypes × 1