I have a requirement that I have to decode and encode a string value with the 3DES algorithm.
Common Crypto which is part of the SDK, appears to have support for 3DES.
However, the documentation about the library is limited and google searches have only come up with limited information.
The one that I found, that I have been using as a base is this one:
Apple - Support - Discussions - Problems with CommonCrypto ...
Over the last few months I have gotten significantly better with Objective-C and this enviornment; I can read the code and understand most of what it is doing. However my attempts to tweek this version to work with 3DES and get the output I need, isn't working.
Anyone out there that can help me the last few inches?
Here is my current code with KEY, INPUT, and what I am looking for in an output:
Code:
NSString *dateString = @"2008-11-24 13:14:17.231";
NSString *sigKey = @"70-248-56-157-134-203-200-22-28-236-253-93-112-161-200-174-164-211-234-22-208-162-13-13";
NSArray *sigKeyArray = [sigKey componentsSeparatedByString:@"-"];
NSString *outVal = @"55-9-145-188-46-202-54-193-31-157-143-148-122-3-194-114-10-242-34-120-142-247-127-10";
CCCryptorStatus ccStatus;
uint8_t *bufferPtr = NULL;
size_t bufferPtrSize = 0;
size_t movedBytes = 0;
size_t plainTextBufferSize = [dateString length];
//uint8_t *iv = NULL; //kCCBlockSize3DES;
bufferPtrSize = (plainTextBufferSize + kCCBlockSize3DES) & ~(kCCBlockSize3DES - 1);
bufferPtr = malloc(bufferPtrSize * sizeof(uint8_t));
memset((void *)bufferPtr, 0x0, bufferPtrSize);
// memset((void *)iv, 0x0, 0);
ccStatus = CCCrypt(
kCCEncrypt,
kCCAlgorithm3DES,
kCCOptionPKCS7Padding,
sigKeyArray,
kCCKeySize3DES,
nil,
dateString,
plainTextBufferSize,
(void *)bufferPtr,
bufferPtrSize,
&movedBytes);
Any help, or even links to another example or a more detailed doc on how to use the library would be greatly appriciated.