-
hex string of salt and iv(initial vector) have to be converted into bytes, of which the length will be half of the original string.
- (NSData *)dataFromHexString {
const char *chars = [self UTF8String];
int i = 0, len = self.length;NSMutableData *data = [NSMutableData dataWithCapacity:len / 2]; char byteChars[3] = {'\0','\0','\0'}; unsigned long wholeByte; while (i < len) { byteChars[0] = chars[i++]; byteChars[1] = chars[i++]; wholeByte = strtoul(byteChars, NULL, 16); [data appendBytes:&wholeByte length:1]; } return data; }
-
Details about CommonCrypto
-
IV has to be 16 bytes.
-
On iOS, you should be using the
CCCrypt*()
functions for AES.
网友评论