Richard Frith-Macdonald wrote:


I already added a simple category of NSData to the Additions library, consisting only of an -MD5Digest method returning an NSData object.
Cool, I'll try to get a gsweb patch in soon...


I'm not sure what the other methods are supposed to do exactly ... the string encoding makes sense where the string is the input to the digest ... but what to do when producing string output? I don't think there is any standard format for representing a digest as a string, unless it's to encode the bytes as pairs of hex digits.
certainly, you can't just use [NSString-initWithData:encoding:] to produce a string as you have no guarantee that the bytes of the digest are valid characters in the encoding you specify.
Actually yes, I did fall into that trap here :-). What I actually meant would probably be something like

@implementation NSData (MD5)
...
- (NSString *)md5String
{
return [[self md5Digest] hexadecimalStringRepresentation]
}
@end
and at that point the encoding wouldn't hav to be dealt with.

and maybe:
@implementation NSString (MD5)
- (NSString *)md5StringUsingEncoding: (NSStringEncoding) enc
{
return [[self dataUsingEncoding: enc] md5String];
}
- (NSString *)md5String
{
return [[self dataUsingEncoding: [isa defaultCStringEncoding] md5String];
}




_______________________________________________
Bug-gnustep mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-gnustep

Reply via email to