-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scrypt producing some weird hash. #225
Comments
That probably is the correct hash. An scrypt hash is 64 bytes of binary data in this case. You probably want to base64 encode it? |
Thanks @cperciva for your response. When I tried to encode it using base64 (I utilized this online tool: https://www.base64encode.org/) the output is: The output above looks really different (pattern-wise) from the one below which I got from printing the output of the "sample-libscrypt-kdf.c" in the repo. Here's what I got: Encoding the above output in base64 using the aforementioned online tool yields: What are your thoughts please? Thanks. |
I doubt that copy&pasting binary data from a terminal window into a website will do what you want. I recommend that you do the base64 conversion before printing anything. I'm not certain how you produced that string from (Separate note: it's not a great idea to run everything as |
Thanks @gperciva for the hint. I'll create a user with non-root access. To produce that string from |
Given what you've described, consider this output:
Even if you know that the initial array has two values, there's no way to distinguish between those two cases. |
Thanks @gperciva . You're right. I appreciate. I am looking for a suitable base64 library to use in encoding the output before printing it like you rightly advised. Can you kindly recommend a library to use? Thanks. |
Sorry, I haven't looked into base64 libraries. I see that https://github.com/technion/libscrypt uses a library from ISC, so that might be a decent place to start. |
Thanks @gperciva. After looking around, I found an implementation from Apple https://opensource.apple.com/source/QuickTimeStreamingServer/QuickTimeStreamingServer-452/CommonUtilitiesLib/base64.c and https://opensource.apple.com/source/QuickTimeStreamingServer/QuickTimeStreamingServer-452/CommonUtilitiesLib/base64.h which I included in my project. Here is the output of a base64 encoded hash:
What are your thoughts please? Thanks. |
If you want to check if that hash is correct, I suggest using an alternate implementation and seeing if it produces the same hash. You might try https://github.com/technion/libscrypt, or something in the "Other scrypt software" list at the bottom of http://www.tarsnap.com/scrypt.html. Alternatively, you could start from the hash, decode it, then use scrypt to decrypt the result. You should end up with the same input that you gave to scrypt in the first place. |
If you want to discuss general development in C++, use of libraries, and how to use hashes, I suggest posting on https://stackoverflow.com/ |
Thanks @gperciva , you've been so helpful. |
I am working on a C++ project that requires some hashing.
I included the scrypt header file in my C++ code as follows:
extern "C" { #include "scrypt-kdf.h" }
I have a function declaration as follows:
int hashPassword(const char* password, const char* salt, uint8_t hashedPasswordOutput[]);
The function definition is as follows:
The problem is I am getting some really weird hash. Output is:
HashedPasswordString is: 8���i��/��} Y��GWg�0GN
Ev��ԥP������ݺLJ5�y\j;ExqZRk�U��������`See Screenshot below:
### More Details:
I am running the project on docker using the GCC:9.1.0 image.
How do I resolve this to get the right hash? Thanks.
The text was updated successfully, but these errors were encountered: