Less Comfy Man Page
crypt - password and data encryption
string crypt (key, salt);
key is a user's typed password.
salt is a two-character string chosen from the set [a-zA-Z0-9./]. This string is used to perturb the algorithm in one ...
If you read the man page of the crypt function it says in one point:
The return value
points to static data whose content is overwritten by
So the first time you call crypt, and assign its return value (which is a pointer to a string) to the coded variable, the coded variable contains the correct encrypted password. But ...
For instance, the brute force search will at some point generate the
same character sequences as in the dictionary, but how would the
program know to avoid re-checking these same values without searching
Maybe you should store the words read from the dictionary and tested in a string array, then when you get to your brute-force ...
The salt is used to influence the encryption process. If you call crypt twice on the same key passing in different salt each time, you'll get different hashes (results).
The salt can be any two characters, each of which is in the set [./0-9A-Za-z]. That's a total of 64 characters. This means that you can have 64^2 possible combinations of 2-character salts ...
First consider the size this elements have in the cs50 appliance.
char = 1byte
char* (pointer) = 4bytes
You are declaring word and initializing it with the pointer returned by malloc, that is fine. But you are allocating:
malloc(sizeof(char*) * 1);
You need to realize that the sizeof(char*) is the size of a pointer, which is 4bytes in the cs50 appliance, ...
So I'm wondering if submitting a program that would work but can't be actually tested is okay and is what is expected from us
It is expected of you to find all the plaintext passwords of the hashed passwords. Your program should terminate in a reasonable amount of time. You can try to crack as many passwords as you want.
By the way, I'm wondering... Is ...
I think I solved it. It seems that I was overwriting my pointer to my allocated memory with another pointer (when I assigned attempt the output of the crypt function (another pointer - to the encoded string)) after calloc'ing attempt, which leaks it. I then tried to free the pointer I received from crypt, which is invalid, as valgrind said (see more here).
Not really. The cause of the error involves some topics that you will study later in the course. I'll try to simplify my answer as much as possible, but don't panic if you don't fully understand what I say because this is often a confusing topic even for students who already got to this stage in the course.
C does not have a type named string. The cs50 ...