cmouse at desteem
Sep 15, 2009, 2:56 AM
Post #5 of 5
On Mon, Sep 14, 2009 at 06:11:17AM -0700, cc10 wrote:
> >This is dangerous, and wrong.
> >scanf("%16s", userPass); is bit more correct.
> Thank you, will fix it.
> >gcry_md_hash_buffer(GCRY_MD_MD5, userPassHash, userPass, strlen(userPass));
> Tried it both ways (1, and GCRY_MD_MD5), still won't give me the right hash.
> It is weird as it seems the beginning is right, and then it's a bunch of
Did you initialize the library correctly?
Here's how I would do this:
if (!gcry_check_version(GCRYPT_VERSION)) exit(1);
fgets(pw, sizeof pw, stdin); // prevents buffer overflow
gcry_md_hash_buffer(GCRY_MD_MD5, hash, pw, strlen(pw));
for (i = 0; i < sizeof hash; i++)
Gcrypt-devel mailing list
Gcrypt-devel [at] gnupg