i have used this function for 3des encryption.
ccStatus = CCCrypt(kCCEncrypt, // CCoperation op
kCCAlgorithm3DES, // CCAlgorithm alg
kCCOptionPKCS7Padding, // kCCOptionPKCS7Padding, //kCCModeECB, // CCOptions
[_keyData bytes], // const void *key
kCCKeySize3DES, // 3DES key size length 24 bit
vinitVec, //iv, // const void *iv,
[dTextIn bytes], // const void *dataIn
[dTextIn length], // size_t dataInLength
bufferPtr, // void *dataOut
bufferPtrSize, // size_t dataOutAvailable
&movedBytes); // size_t *dataOutMoved
NSData *myData = [NSData dataWithBytes:(const void *)bufferPtr length:(NSUInteger)movedBytes];'
Although it is working. but when i convert convert this NSData to NSString , because the NSString contain lots of null termination,NSString end up on first null termination, the variable is not able to contain the whole data. but i have to send encrypted string on the server. what can i do to convert NSData to NSString. string that contain all data means(if the data contain null termination. the string will not end up in that case)?
Please help Thanks in advance.
thanks for reply , look if the encrypted byte contain
char bytes[] = { 'H', 'e', 'l', 'l', 'o', \0, 'W', 'o', 'r', 'l', 'd', \0 };
NSData *data = [NSData dataWithBytes:bytes length:sizeof(bytes)];
NSString *str = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"%@", str);
NSString *sendtoserver=[NSString stringwithformat:@"<request>%@</request>",str];
when we convert these NSData to NSString. it will end on first \0 ( null termination) because we have to send encrypted NSString.so it is making problem. and i can't send the base64string because server side don't want that.they were asking for encrypting string.
so what i do now , please help and thanks again for reply sir,