On 01.04.20 19:46, H. Nikolaus Schaller wrote:
> 
>> Am 01.04.2020 um 19:43 schrieb Andreas Höschler <[email protected]>:
>>
>> Hi all,
>>
>> I have the following NSString category 
>>
>>   @implementation NSString (NSStringJsonExtension)
>>   
>>   - (NSString *)md5
>>     {
>>      #ifdef __APPLE__
>>      const char *cStr = [self UTF8String];
>>      unsigned char result[CC_MD5_DIGEST_LENGTH];
>>      CC_MD5( cStr, (int)strlen(cStr), result ); // This is the md5 call
>>      return [NSString stringWithFormat:
>>      @"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
>>      result[0], result[1], result[2], result[3], 
>>      result[4], result[5], result[6], result[7],
>>      result[8], result[9], result[10], result[11],
>>      result[12], result[13], result[14], result[15]
>>      ];  
>>      #else
>>      NSLog(@"md5 not yet supported on GNUstep. Please implement");
> 
> https://linux.die.net/man/3/md5_init
> 
> maybe
>       unsigned char *MD5(cStr, strlen(cStr), result);
> 
> You need to install openssl devel packages.

Nikolaus is quite right here: Please go with one of the tried and true
crytographic libraries (openssl, gnutls, etc.).  But I'll just add a
little context: CC_MD5 is a function (macro? -- I can't recall) from
Apple's CommonCrypto library. We once had a port of CommonCrypto, but
Apple has since rewritten it to depend on CoreCrypto, which is not
available under a free license (you can get the source code for
evaluation, though), so I abandoned that port.

Cheers,

Niels



Reply via email to