Re: generating sha256 hashes with openssl?
- From: "Littlefield, Tyler" <tyler@xxxxxxxxxxxxx>
- To: <programmingblind@xxxxxxxxxxxxx>
- Date: Sun, 22 Aug 2010 17:46:45 -0600
std::string should strcpy though, no?----- Original Message ----- From: "Dave" <davidct1209@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx> Sent: Sunday, August 22, 2010 5:42 PM Subject: Re: generating sha256 hashes with openssl?
From a cursory glance at the function (and without knowing what exactly failed), it potentially looks like you have a dangling pointer. You assign to your password class member an array of characters which you created on the heap (and then delete). On 8/22/10, Littlefield, Tyler <tyler@xxxxxxxxxxxxx> wrote:Hello all, I've been trying to figure this out based on documentation from openssl(what little there is) and some info from google, but it still seems to be failing: Any ideas would be great on where I might be going wrong; here isthe function void Player::SetPassword(const std::string &s) { SHA256_CTX context; unsigned char *hash = new unsigned char[SHA256_DIGEST_LENGTH+1]; memset(hash, 0, SHA256_DIGEST_LENGTH+1); SHA256_Init(&context); SHA256_Update(&context, (unsigned char*)s.c_str(), s.length()); SHA256_Final(hash, &context); _password=(char*)hash; delete []hash; } Thanks, Ty__________ View the list's information and change your settings at http://www.freelists.org/list/programmingblind
__________View the list's information and change your settings at http://www.freelists.org/list/programmingblind
- Follow-Ups:
- References:
- generating sha256 hashes with openssl?
- From: Littlefield, Tyler
- Re: generating sha256 hashes with openssl?
- From: Dave
- generating sha256 hashes with openssl?
Other related posts:
- » generating sha256 hashes with openssl? - Littlefield, Tyler
- » Re: generating sha256 hashes with openssl? - Dave
- » Re: generating sha256 hashes with openssl? - Littlefield, Tyler
- » Re: generating sha256 hashes with openssl? - Dave
- » Re: generating sha256 hashes with openssl? - Dave
- » Re: generating sha256 hashes with openssl? - Littlefield, Tyler
- » Re: generating sha256 hashes with openssl? - Littlefield, Tyler
- » Re: generating sha256 hashes with openssl? - Dave
- » Re: generating sha256 hashes with openssl? - Littlefield, Tyler
- » Re: generating sha256 hashes with openssl? - Dave
- » Re: generating sha256 hashes with openssl? - Dave
- » Re: generating sha256 hashes with openssl? - Littlefield, Tyler
- » Re: generating sha256 hashes with openssl? - Littlefield, Tyler
- » RE: generating sha256 hashes with openssl? - Sina Bahram
- » Re: generating sha256 hashes with openssl? - Littlefield, Tyler
- » Re: generating sha256 hashes with openssl? - Dave
- » RE: generating sha256 hashes with openssl? - Sina Bahram