Hot answers tagged

6

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 argument is the password to be encrypted, and salt is a two character string that 'tweaks' the algorithm's output. The output is a 13 character string. The first ...


6

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 using functions without reading and understanding the doc. Except maybe on a beautiful, sunny, lazy, Sunday afternoon :)


6

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 single character. You need to pass this char array ['a', '\0'], not this char 'a'. A simple fix can be to declare a char array with a length of 2, with the second ...


2

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 crypt causes the clang error "incompatible integer to pointer conversion" Try to use a string as salt.


2

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 ...


2

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 Verified"); } You can go to this link for a better understanding! (Or refer to login.php in public directory of pset7) php.net/manual/en/function.crypt.php


2

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 be done either in the compilation command (cc -DMACRO=value) or by defining the macro within the source code before including any ...


2

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 function. And there's no need for specifying an explicit null terminator in a string literal, as it contains an implicit one, but using a list of char (salt2), it'...


2

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', 'a'} and then use that with crypt, crypt will be expecting a string so it may not be "aaaa" but "aaaaaxyz" where x,y,z happen to be the next bytes of memory ...


2

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 of a Linux system. I think there's a bit more on that in the problem's page, but if you're new you might still miss that bit.


1

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 output. And here's a problem: The array output got declared on to_password's stack. When it returns, that area of the stack will be marked as "unused" (the ...


1

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 corrected. Thanks for the report.


1

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 to the top even above the other includes in your header, it will compile fine.


1

for (int k = 0; k < 0; k++) This loop will never be entered, as initial value 0 is not <0


1

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: 50YHuxoCN9Jkc with this modification it returns two character Password which is 'JH' ( this is your code, i just modified to check two characters only as you can see ) ...


1

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 the while loop condition, so they keep on going on till the letters in key are "zzzz" and if the password you gave is not "zzzz" the while loop condition (which ...


1

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.


1

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 the code around. That line itself does not determine your programme's return value, that is determined by a return statement in main.


1

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 equation above. However, in this specific example, you could find a value of d that would satisfy the equation easily since 925 % 924 = 1 and we're lucky that e is ...


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