Hot answers tagged

6 votes
Accepted

Crack - launching and crypt function

crypt() is an encryption algorithm. It takes a plaintext string (a user password), and encrypts it, so that it can be stored in a file. char *crypt(const char *key, const char *salt) The key ...
user avatar
6 votes
Accepted

pwd_context.encrypt Depreciation Warning Pset7

Use hash instead of encrypt in your register function. I tried it, it worked for me. I was able to sign on as an existing user, or register (and sign on as) a new user. I am not advocating blindly ...
user avatar
6 votes
Accepted

PSET2: CRACK vs POINTERS

Your problem is that letters[i] is a char, but the crypt() function expects a char * (string) as its first argument. So what you really want to do is pass a string with a single character, not a ...
user avatar
  • 7,326
2 votes
Accepted

The crypt function won't work, despite me linking the crypt library

Here on my Fedora Box and also in the appliance the man crypt has the following prototype of crypt: char *crypt(const char *key, const char *salt); I would say, that the 1000 in your call to ...
user avatar
2 votes
Accepted

What's the purpose of the 'salt' string? Isn't it contained in the hashed string anyway?

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 ...
user avatar
  • 17.3k
2 votes

Using crypt function for comparing password hashes

For comparison, crypt function is used in a slightly different way. It accepts 2 arguments. if ( (crypt(str $user_input, $password_hash) == $password_hash) { ....... echo("Password ...
user avatar
2 votes
Accepted

Crypt() includes and compiling

It will work when constructed as in the man page. From man feature_test_macros: NOTE: In order to be effective, a feature test macro must be defined before including any header files. This can ...
user avatar
2 votes
Accepted

Use of crypt function - comparing output

Strings in C are pointers to char, pointing to the first character in the string, so the value you compared is a memory address. To compare strings by content rather than by address, use the strcmp ...
user avatar
  • 20.7k
2 votes
Accepted

PSet2 - Why does crack only work with four characters or less?

It doesn't work for 5 characters because you haven't allocated enough space for a 5-char string with char word[5]; Remember the null char! As a consequence, when you set word = {'a', 'a', 'a', 'a', ...
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
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

Basic use of crypt in crack.c? (Hash "ROLF")

Unfortunately, there was a typo in the spec. The first example given was correct: ./crack 50fkUxYHbnXGw rofl but when repeated later in the spec, it showed ROFL in error. This has been ...
user avatar
  • 18.3k
1 vote
Accepted

crack.c: error: implicit declaration of function 'crypt' is invalid in C99

The spec is perfectly correct. More than likely, you don't have #define _XOPEN_SOURCE #include <unistd.h> At the very top of your program (ie, before any other #includes). If you move that ...
user avatar
  • 18.3k
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

CS50 2017 crack.c not working properly

Your code doesn't wrong actually but your assuming that passwords have four characters only because of this wrong assumption some of hashes doesn't return anything. for example try this hash: ...
user avatar
1 vote

PSET2: Can't figure out what's wrong with my crack.c code?

The problem is that you have essentially created an infinite loop. Initially when your while code starts, your first for loop runs, then your second, then third and then fourth but they never check ...
user avatar
1 vote
Accepted

Usage of Crypt Function?? Correct usage?

Yes my crypt function is working just like that. There is fault in other part of my code, but my crypt function is working properly. The above usage I posted works for the crypt function.
user avatar
1 vote

Usage of Crypt Function?? Correct usage?

If those strings have the correct values (salt should be a two-character string, which takes three bytes in memory, two plus one for the null terminator), then this might be right. Totally depends on ...
user avatar
  • 20.7k
1 vote

Why is d = 185 to satisfy de = 1 mod m (where m = 924)? (Wk2, shorts: cryptography)

de = 1 (mod m) where e is equal to 5 and m is equal to 924 means (5 * d) % 924 = 1 Thomas later in the video used the extended Euclidean algorithm to find a value of d that would satisfy the ...
user avatar
  • 17.3k

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