Sé que SHA-1 es preferible, pero este proyecto requiere que use MD5.¿Cómo creo un Hash MD5 de una cadena en Cocoa?
#include <openssl/md5.h>
- (NSString*) MD5Hasher: (NSString*) query {
NSData* hashed = [query dataUsingEncoding:NSUTF8StringEncoding];
unsigned char *digest = MD5([hashed bytes], [hashed length], NULL);
NSString *final = [NSString stringWithUTF8String: (char *)digest];
return final;
}
Tengo este código de una respuesta a otra pregunta similar en StackOverflow, pero me sale el siguiente error del BGF cuando el programa se rompe en retorno final;
(gdb) p digest
$1 = (unsigned char *) 0xa06310e4 "\0206b\260/\336\316^\021\b\a/9\310\225\204"
(gdb) po final
Cannot access memory at address 0x0
(gdb) po digest
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0xb0623630
0x98531ed7 in objc_msgSend()
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off"
Evaluation of the expression containing the function
(_NSPrintForDebugger) will be abandoned.
No puedo hacer ningún sentido.
Esto funciona bien, gracias. – demonslayer319
Yo uso esto también. ¡Gracias! – swdev
¿Esto requiere IOS6? –