Closed ahsanghauri closed 5 years ago
mytext: 1234 crypto: LXY1ElqyWvsPV+YaRf6FdoY3GNUbijO4bKUwlcJTmuA= decrypt: cannot decrypt key: mykey cannot decrypting , in ios13, xcode 11, macos catalina, Please help.
same issue
same issue decryption not working on IOS 13
Will look into it
I am having the same problem just started to debug. It is not refreshing the encryption on login. I will let you know if I find anything out
I have partially gone through apples code and have not seen any major changes to the lib as of yet. I did change a little code in order to get a new encrypted password each time, which wasn't working properly. My server has been throwing Errors only on Xcode 11 builds so it is clearly something in Xcode11.
The sha256 for the same key on iOS12 and iOS13 are different, the problem could be somewhere there. The return value for CryptLib().sha256("placeholderKey", length: 32)
is
iOS13 0x8cce86e407960
iOS12 0x8cce86e407960550edf12b4ebbc16cb7
@skavinvarnan @Farcvel @squshipillow @ahsankhatri
Inside:
- (NSString*) sha256:(NSString *)key length:(NSInteger) length
I replaced
NSString *hash=[out description];
To
NSString *hash=[out debugDescription];
And everything got back to normal
worked for me, awesome!
@skavinvarnan @Farcvel @squshipillow @ahsankhatri
Inside:
- (NSString*) sha256:(NSString *)key length:(NSInteger) length
I replaced
NSString *hash=[out description];
ToNSString *hash=[out debugDescription];
And everything got back to normal
31
thanks man work fine now
@skavinvarnan @ahsankhatri
I have found another issue with the decryption method -decryptCipherText: key : iv:
`- (NSString ) decryptCipherText:(NSString )ciperText key:(NSString )key iv:(NSString )iv {
return [[NSString alloc] initWithData:[[CryptLib alloc] decrypt:[[NSData alloc] initWithBase64EncodedString:ciperText options:NSDataBase64DecodingIgnoreUnknownCharacters] key:[[CryptLib alloc] sha256:key length:32] iv:[[CryptLib alloc] generateRandomIV16]] encoding:NSUTF8StringEncoding];
}
Please see that the above method does not use the given argument for iv and it generates a random IV instead. This will also results invalid result while decrypting data. Please look into this and kindly change accordingly.
Thanks in advance.
Refer below link. https://stackoverflow.com/questions/58098958/aes-encryption-cryptlib-in-ios-13-not-working You can use for nsdata to hex conversion below
-(NSString)hex:(NSData)data{ NSMutableData result = [NSMutableData dataWithLength:2data.length]; unsigned const char src = data.bytes; unsigned char dst = result.mutableBytes; unsigned char t0, t1;
for (int i = 0; i < data.length; i ++ ) {
t0 = src[i] >> 4;
t1 = src[i] & 0x0F;
dst[i*2] = 48 + t0 + (t0 / 10) * 39;
dst[i*2+1] = 48 + t1 + (t1 / 10) * 39;
}
return [[NSString alloc] initWithData:result encoding:NSASCIIStringEncoding];
}
debugDescription
Work for me (thanks)
@skavinvarnan @Farcvel @squshipillow @ahsankhatri Inside:
- (NSString*) sha256:(NSString *)key length:(NSInteger) length
I replacedNSString *hash=[out description];
ToNSString *hash=[out debugDescription];
And everything got back to normal31
thanks you man work fine now
`NSString *hash=[out debugDescription];
Inside:
decryption work fine pervious version but not working on IOS 13.please help