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 8970661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:45:46+00:00 2026-06-15T17:45:46+00:00

i have used this function for 3des encryption. ccStatus = CCCrypt(kCCEncrypt, // CCoperation op

  • 0

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,

  • 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-15T17:45:47+00:00Added an answer on June 15, 2026 at 5:45 pm

    Converting NSData to NSString does not stop at null bytes. A NSString can contain arbitrary Unicode characters, including embedded “NULL” characters.

    Example:

    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);
    

    Output:

    Hello
    

    So it looks as if the string contains only 5 characters and the conversion stopped at the first null byte. But that is only the NSLog output, in fact nothing is lost:

    for (int i = 0; i < [str length]; i++) {
        unichar c = [str characterAtIndex:i];
        NSLog(@"%2d, %3d, %c", i, c, c);
    }
    

    Output:

      0,  72, H
      1, 101, e
      2, 108, l
      3, 108, l
      4, 111, o
      5,   0, 
      6,  87, W
      7, 111, o
      8, 114, r
      9, 108, l
     10, 100, d
     11,   0, 
    

    So the string contains all data and nothing is lost. Probably the string is truncated later, when you send it to the server.


    REMARK: Converting the encrypted data to a string seems problematic to me, because the data is interpreted in some character encoding. I have chosen NSASCIIStringEncoding in this example, but according to the documentation this encoding is only valid for ASCII values 0…127.

    If you add more information on how and in which format the encrypted data is sent to the server, we might be able to make suggestions how so solve this better.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used this function to convert string to bits. def a2bits(chars): return bin(reduce(lambda
I have used Javascript onlaod like this: function check() { var pic = new
I have a problem when call applet method from javascript.. I used this function
I have an ASP .NET page where I use jQuery. I used this function
i have used this function in my app for return the model name of
I have used this php to fetch my blog's latest post: function read_rss($display=0,$url='') {
I have used the get_or_create function on my models in Django. This function returns
I have used this javascript function: $(document).ready(function(){ $(td).each(function() { if (parseInt($(this).text()) > 0) {
I have used this function to speak sentence ascynchronously . m_cpVoice->Speak(m_sInputText,SPF_ASYNC, NULL)) I want
I have used JavaScript on body onload event I used this code: function timeMsg()

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.