
cmouse at desteem
Sep 15, 2009, 2:56 AM
Post #5 of 5
(1089 views)
Permalink
|
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 > f's. > Did you initialize the library correctly? Here's how I would do this: { char pw[16]; char hash[16]; int i; if (!gcry_check_version(GCRYPT_VERSION)) exit(1); gcry_control(GCRYCTL_DISABLE_SECMEM, 0); gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); 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++) printf("%02x", hash[i]); printf("\n"); } Aki Tuomi _______________________________________________ Gcrypt-devel mailing list Gcrypt-devel [at] gnupg http://lists.gnupg.org/mailman/listinfo/gcrypt-devel
|