[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MD5 encryption?
From: |
Richard Frith-Macdonald |
Subject: |
Re: MD5 encryption? |
Date: |
Thu, 17 Jan 2002 12:37:38 +0000 |
On Thursday, January 17, 2002, at 12:07 PM, <anstouh@yahoo.com.au> wrote:
I was just wondering how I could encrypt a string given an MD5 hash from
within a GNUstep program (written in Objective C)? I would prefer it if
the response was detailed; I'm not all that familiar with Obj-C.
I'm not sure what you mean ...
If you want to generate the MD5 hash of a string I'd use some C library
(such as openssl) to do it (unless you want to write the MD5 support
yourself).
Since the MD5 stuff works on raw data, you would generally pass a
pointer to
the data and a length as arguments to the hashing function.
If you are working with unicode strings, you would do something like -
NSData *data = [theString dataUsingEncoding: NSUnicodeStringEncoding];
/*
* Call some hashing function passing it a pointer to the data to be
hashed,
* the length of that data, and a pointer to a buffer in which the hash
is
* to be stored.
*/
md5hash([data bytes], [data length], theHash);
If your string is plain ascii, you would use
[theString dataUsingEncoding: NSASCIIStringEncoding]
etc.
- MD5 encryption?, anstouh, 2002/01/17
- Re: MD5 encryption?,
Richard Frith-Macdonald <=