title: How to encrypt the NSString value using DES in iPhone?
body: <p>I used following code to encrypt the NSString value with Key,</p>
  
  <pre><code>NSString *token = @"encryptValue";
  NSString *key = @"encryptKey";
  
  NSData * keyData = [key dataUsingEncoding: NSUTF8StringEncoding];
  NSData * plainData = [token dataUsingEncoding: NSUTF8StringEncoding];
  NSMutableData * encData = [NSMutableData dataWithLength: plainData.length + 256];
  size_t bytesWritten = 0;
  CCCryptorStatus ccStatus = CCCrypt (kCCEncrypt,
                      kCCAlgorithmDES,
                      kCCOptionPKCS7Padding,
                      [keyData bytes], 
                      kCCKeySizeDES,
                      NULL,
                      [plainData bytes],
                      [plainData length],
                      encData.mutableBytes,
                      encData.length,
                      &amp;bytesWritten);
  encData.length = bytesWritten;    
  NSString *encrypted = [[NSString alloc]  initWithBytes:[encData bytes] length:[encData length] encoding: NSUTF8StringEncoding];  
  NSLog(@"ENCRYPT : %@",encrypted); 
  </code></pre>
  
  <p>But I'm getting (null) is the result. Is anything wrong? How to encrypt the NSString value?</p>