navneet83 / Cross-platform-AES-encryption

Basic cross platform AES encryption
Apache License 2.0
320 stars 152 forks source link

Facing problem while decryption in iphone5 #56

Open shwetalodhe opened 6 years ago

shwetalodhe commented 6 years ago

Hi, I am using this code of AES256 encryption in iphone app.This giving expected output in all device higher than iphone5 simualator(version 10.0). While converting the encrypted NSdata to nsstring using NSUTF8StringEncoding its returning nil nsstring.Unable to understand reason.Can anyone help on this. Also find the code which i am using for conversion

NSString cipherText =@"1xZKEyLmVzKDoA+2+G2xiA=="; NSString ivRandom = @"54327CD65463ECAB"; NSString key = @"B98MN8C9A8765BCA"; NSData nsdataFromBase64String = [[NSData alloc] initWithBase64EncodedString:cipherText options:0];

NSData *dataDecrypt = [cryptoLib decrypt:nsdataFromBase64String key:key iv:ivRandom];
NSString *base64Decoded = [[NSString alloc]
                           initWithData:dataDecrypt encoding:NSUTF8StringEncoding];