Re: FoundationKit md5/checksum
Re: FoundationKit md5/checksum
- Subject: Re: FoundationKit md5/checksum
- From: Chris Ridd <email@hidden>
- Date: Fri, 25 Jul 2003 19:11:59 +0100
On Friday, July 25, 2003, at 06:23PM, Nick Zitzmann <email@hidden> wrote:
>
On Friday, July 25, 2003, at 09:45 AM, Chris Long wrote:
>
>
> Does foundation kit have anything similar to and md5 or a cksum. Im
>
> looking to avoid and NSTask, need something internal.
>
>
There isn't any way to do this in Foundation. You can do this
>
internally by using libcrypto and its MD5 calculation functions,
>
though... See the header "md5.h".
>
>
Nick Zitzmann
>
AIM/iChat: dragonsdontsleep
>
Check out my software page: http://seiryu.home.comcast.net/
>
>
Famous last words: "OK, I've pulled the pin. Now what? Where are you
>
going?"
I wrote a category on NSData a while back which computes an MD5 hash:
#include <openssl/evp.h>
#include <openssl/err.h>
// Compute an MD5 digest.
- (NSData *)MD5
{
EVP_MD_CTX mdctx;
unsigned char md_value[EVP_MAX_MD_SIZE];
int md_len;
EVP_DigestInit(&mdctx, EVP_md5());
EVP_DigestUpdate(&mdctx, [self bytes], [self length]);
EVP_DigestFinal(&mdctx, md_value, &md_len);
return [NSData dataWithBytes: md_value length: md_len];
}
It uses the OpenSSL /usr/lib/libcrypto.dylib, so you'll need to link against that. The OpenSSL headers are not installed on 10.1, IIRC, though the library itself is.
Cheers,
Chris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.