2010-11-05 4 views

Répondre

4

Il y a une fonction SHA1 dans OpenSSL lib (lien avec option de liaison -lcrypto):

#include <openssl/sha.h> 

NSMutableData *hashData = [NSMutableData dataWithLength:SHA_DIGEST_LENGTH]; 
SHA1([input bytes], [input length], [hashData mutableBytes]); 
+0

-t-il revenir un NSString? parce que si je l'utilise comme [CODE] NSMutableData * hashData = [NSMutableData dataWithLength: SHA_DIGEST_LENGTH]; \t NSString * temp = [[NSString alloc] initWithString: SHA1 ([mes octets de données], [longueur de mes données], [hashData mutableBytes])]; [/ CODE] Je reçois EXC_BAD_ACCESS – Knodel

+0

Non. Vous pouvez faire une [hashData description] après avoir appelé SHA1 pour retourner un NSString. – diederikh

+0

Merci! Ça marche! – Knodel