The Security services API doesn't appear to allow me to compute a hash directly. There are plenty of public domain and liberally licensed versions available, but I'd rather use a system library implementation if possible.
The data is accessible via NSData, or plain pointers.
The cryptographic strength of the hash is important to me. SHA-256 is the minimum acceptable hash size.
I cleaned up https://stackoverflow.com/a/13199111/1254812 a bit and structured it as an
NSString
extensionHere's a pretty similar one based on NSString
(Credits go to http://www.raywenderlich.com/6475/basic-security-in-ios-5-tutorial-part-1)
This is what worked for me
This is what I'm using for SHA1:
Replace
CC_SHA1
withCC_SHA256
(or whichever you need), as well asCC_SHA1_DIGEST_LENGTH
withCC_SHA256_DIGEST_LENGTH
.Below link i used for creating document hash value and Its very simple and easy to calculate hash value specially for large files.
Link : http://www.joel.lopes-da-silva.com/2010/09/07/compute-md5-or-sha-hash-of-large-file-efficiently-on-ios-and-mac-os-x/comment-page-1/#comment-18533