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/
user avatar
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 ...
user avatar
  • 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 ...
user avatar
  • 7,326
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 ...
user avatar
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=...
user avatar
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=='...
user avatar
  • 20.7k
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?
user avatar
  • 18.3k
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 ...
user avatar
  • 20.7k
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 ...
user avatar
  • 63.4k
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 ...
user avatar
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 ...
user avatar
  • 20.7k
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 ...
user avatar
  • 5,172
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....
user avatar
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 ...
user avatar
  • 20.7k
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 = ...
user avatar
  • 20.7k
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 ...
user avatar
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 ...
user avatar
  • 18.3k
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: ...
user avatar
  • 63.4k
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
user avatar
  • 5,172
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 ...
user avatar
  • 63.4k
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 ...
user avatar
  • 18.3k
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 ...
user avatar
  • 63.4k
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
user avatar
  • 20.7k
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 ...
user avatar
  • 18.3k
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 ...
user avatar
  • 18.3k
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 ...
user avatar
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: ...
user avatar
  • 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 ...
user avatar
  • 63.4k

Only top scored, non community-wiki answers of a minimum length are eligible