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

  • SEARCH
  • Home
  • 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 8233355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:06:06+00:00 2026-06-07T18:06:06+00:00

When I encrypt a string then immediately decrypt, the CCCryptorStatus is -4304 and the

  • 0

When I encrypt a string then immediately decrypt, the CCCryptorStatus is -4304 and the resultant decoded string is not the proper length. Can anyone see what I might be doing wrong?

//Encrypt

NSString *plainText = @"e22ae25e-0b20-433a-8aa5-a5678714f590";
NSData *rawData = [plainText dataUsingEncoding:NSUTF8StringEncoding];
size_t outLength;
NSMutableData *cipherData = [NSMutableData dataWithLength:rawData.length + kCCBlockSizeAES128];
CCCryptorStatus cryptStatus = CCCrypt(kCCEncrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding, [AESKey bytes], [AESKey length],  NULL, [rawData bytes], [rawData length], [cipherData mutableBytes], [cipherData length], &outLength);

//[plainText length] = 36
//[rawData length] = 36
//[cipherData length] = 52
//outLength = 48

//Decrypt

NSMutableData *decodedData = [NSMutableData dataWithLength:cipherData.length + kCCBlockSizeAES128];

//[decodedData length] = 68

CCCryptorStatus cryptStatus2 = CCCrypt(kCCDecrypt, kCCAlgorithmAES128, kCCOptionPKCS7Padding, [AESKey bytes], [AESKey length], NULL, [cipherData bytes], [cipherData length], [decodedData mutableBytes], [decodedData length], &outLength);
NSString *decodedString = [[NSString alloc] initWithData:decodedData encoding:NSUTF8StringEncoding];

//[decodedData length] = 68
//[decodedString length] = 68

/*
    At this point, cryptStatus2 is -4304 and 
    decodedString = "e22ae25e-0b20-433a-8aa5-a5678714f590\f\f\f\f\f\f\f\f\f\f\f\f";

*/
  • 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-07T18:06:08+00:00Added an answer on June 7, 2026 at 6:06 pm

    That’s a kCCAlignmentError according to the header file. Try to use outlength instead of [cipherData length].

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

Sidebar

Related Questions

I tried to encrypt an array then decrypt it back to string by calling
I'm trying to encrypt a string in Java on Android, and then decrypt it
I'm trying to encrypt a string, save it in a file and then later
i want to encrypt string in java and decrypt the same string in C#
I am trying to encrypt a string then covert it into a base64_encode string
I need to encrypt a string using MySQL's AES_ENCRYPT function, then attach that encrypted
I use openssl. First off I created private/public keys, then I encrypt a string
I'm trying to figure out how to encrypt / decrypt a string in VB.Net.
I encrypt and decrypt a string with a private key and following functions. so
I encrypt the string usingAES using AES 256 and delete the key file. Then

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.