Hash a password string using SHA512 like C?

This function will hash a string using SHA512. The resulting string is a hex representation of the hash: (NSString *) createSHA512:(NSString *)source { const char *s = source cStringUsingEncoding:NSASCIIStringEncoding; NSData *keyData = NSData dataWithBytes:s length:strlen(s); uint8_t digestCC_SHA512_DIGEST_LENGTH = {0}; CC_SHA512(keyData. Bytes, keyData.

Length, digest); NSData *out = NSData dataWithBytes:digest length:CC_SHA512_DIGEST_LENGTH; return out description; } Don't forget to include the correct header: include.

This function will hash a string using SHA512. The resulting string is a hex representation of the hash: + (NSString *) createSHA512:(NSString *)source { const char *s = source cStringUsingEncoding:NSASCIIStringEncoding; NSData *keyData = NSData dataWithBytes:s length:strlen(s); uint8_t digestCC_SHA512_DIGEST_LENGTH = {0}; CC_SHA512(keyData. Bytes, keyData.

Length, digest); NSData *out = NSData dataWithBytes:digest length:CC_SHA512_DIGEST_LENGTH; return out description; } Don't forget to include the correct header: #include.

Oh, thanks you so much, I will try it right now! – Son Nguyen Sep 30 '10 at 9:04 Dear Philippe, it's working well, thanks! – Son Nguyen Sep 30 '10 at 9:48 Dear Philippe, I have a problem that when comparing hashed passwords are different between C# and objective-c.In my C# code, I used SecureString to store password, so I have to use Marshal Copy to get byte array and I saw that there are 0bytes appended after each password's char, maybe that's cause the hashed pass are different.

I don't know how to resolve it, could you please help me again? Thanks! – Son Nguyen Oct 1 '10 at 4:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions