title: DES encryption with objective c
body: <p>I am trying to encrypt data in objective c with DES algorithm. Here is my code. I am getting my data :&lt;> and encrypted str: from this code. Can anyone say what is wrong please?    </p>
  
  <pre><code>    NSString *token = @"hello world";
      const void *vplainText;
      size_t plainTextBufferSize;
  
      plainTextBufferSize = [token length];
      vplainText = (const void *) [token UTF8String];
  
      uint8_t *bufferPtr = NULL;
      size_t bufferPtrSize = 0;
      size_t *movedBytes;
  
      bufferPtrSize = (plainTextBufferSize + kCCBlockSize3DES) &amp; ~(kCCBlockSize3DES - 1);
      bufferPtr = malloc( bufferPtrSize * sizeof(uint8_t));
      memset((void *)bufferPtr, 0x0, bufferPtrSize);
  
      NSString *key = [[NSString alloc] initWithString:@"12345678"];
      const void *vkey = (const void *) [key UTF8String];
      CCCryptorStatus cryptStatus =CCCrypt(
                              kCCEncrypt,         /* kCCEncrypt, etc. */
                              kCCAlgorithmDES,        /* kCCAlgorithmAES128, etc. */
                             kCCOptionPKCS7Padding | kCCOptionECBMode,    /*kCCOptionPKCS7Padding, etc. */
                              vkey,
                              kCCKeySizeDES,
                              NULL,           /* optional initialization vector */
                              vplainText,     /* optional per op and alg */
                              plainTextBufferSize,
                              (void *)bufferPtr,          /* data RETURNED here */
                              bufferPtrSize,
                              movedBytes);
  
      NSString *result;
  
      NSData *myData = [NSData dataWithBytes:(const void *)bufferPtr length:(NSUInteger)movedBytes];
      NSLog(@"my data :%@",myData);
  
  
      result = [self base64Encoding:myData];
      NSLog(@"enrypted str: %@",result);
  </code></pre>