Decrypt encrypted string in iOS using MD5 algorithm
encryption, ios, md5, nsstring, objective-c
Solution
Yes, it is true. MD5 is a one-way hash function. You can compare two MD5-hashed strings to check if the original plain inputs were equal.
Take a look at the AES encryption for NSString discussion here.
Problem
Basically I want to encrypt and decrypt password in `iOS`. So far I have used following method to encrypt password ``` - (NSString *) stringFromMD5{ if(self == nil || [self length] == 0) return nil; const char *value = [self UTF8String]; unsigned char outputBuffer[CC_MD5_DIGEST_LENGTH]; CC_MD5(value, strlen(value), outputBuffer); NSMutableString *outputString = [[NSMutableString alloc] initWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; for(NSInteger count = 0; count < CC_MD5_DIGEST_LENGTH; count++){ [outputString appendFormat:@"%02x",outputBuffer[count]]; } return [outputString autorelease]; } ``` This is using `MD5` hash to encrypt string. Question: - As I read somewhere it is not possible to decrypt `MD5` hash. Is this really true ? If no then can you please guide me on decryption using `MD5`. - If first one is not possible then are there any other alternatives to both encrypt and decrypt `NSString` in `iOS`. I really welcome your suggestions on this please.