Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7974097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:16:34+00:00 2026-06-04T08:16:34+00:00

I used following code to encrypt the NSString value with Key, NSString *token =

  • 0

I used following code to encrypt the NSString value with Key,

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,
                    &bytesWritten);
encData.length = bytesWritten;    
NSString *encrypted = [[NSString alloc]  initWithBytes:[encData bytes] length:[encData length] encoding: NSUTF8StringEncoding];  
NSLog(@"ENCRYPT : %@",encrypted); 

But I’m getting (null) is the result. Is anything wrong? How to encrypt the NSString value?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:16:36+00:00Added an answer on June 4, 2026 at 8:16 am

    Finally I done with following code and now its working fine.

    - (NSString*) doCipher:(NSString*)encryptValue {
    
        const void *vplainText;
        size_t plainTextBufferSize = [encryptValue length];
        vplainText = (const void *) [encryptValue UTF8String];    
        CCCryptorStatus ccStatus;
        uint8_t *bufferPtr = NULL;
        size_t bufferPtrSize = 0;
        size_t movedBytes = 0;
    
        bufferPtrSize = (plainTextBufferSize + kCCBlockSizeDES) & ~(kCCBlockSizeDES - 1);
        bufferPtr = malloc( bufferPtrSize * sizeof(uint8_t));
        memset((void *)bufferPtr, 0x0, bufferPtrSize);
    
        Byte iv [] = {0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef};
    
        NSString *key = @"encryptKey";
        const void *vkey = (const void *) [key UTF8String];
    
        ccStatus = CCCrypt(kCCEncrypt,
                           kCCAlgorithmDES,
                           kCCOptionPKCS7Padding,
                           vkey, 
                           kCCKeySizeDES,
                           iv,
                           vplainText,
                           plainTextBufferSize,
                           (void *)bufferPtr,
                           bufferPtrSize,
                           &movedBytes);
    
        NSData *myData = [NSData dataWithBytes:(const void *)bufferPtr length:(NSUInteger)movedBytes];
        NSString *result = [myData base64Encoding]; 
    
       return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used the following code to post a search value via an html button.
I used following code to generate a heatmap using heatmap.2 of R. key=F gets
I used following code, but it displays only 2 digit of ISO country name.
i have used following code to repeat a process creation/close iteratively dim vProcessInfo as
I have used following code to create a simple PDF file. It executes fine
I am trying to used following code but I am not getting good performance
I've used following code snippet for my activity in order to deal with orientation
I've used following code for parsing XML file in c++. http://www.codeproject.com/Articles/176236/Parsing-an-XML-file-in-a-C-C-program . Now I
I used following JS code to create equal height columns: var colHeight = Math.max($('.3columngallery
I used the following code to get the path Path errorFilePath = FileSystems.getDefault().getPath(errorFile); When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.