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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:36:29+00:00 2026-05-18T12:36:29+00:00

I have an issue when communicating encrypted between iOS and PHP. I have an

  • 0

I have an issue when communicating encrypted between iOS and PHP. I have an app that encrypts a string and sends it to a PHP server that decrypts it. That part works just fine. Now the PHP server needs to send an encrypted response back to the app, which seems to be causing a bit
more gray hair.

The issue is, that when I encrypt a string in PHP it looks different from the same string encrypted in iOS and even .NET – obviously all places use the same algorithm, key and IV.

I use Rijndael 128 in CBC mode with an IV consisting of empty bytes (so far).

The PHP encryption looks so:

$encrypted = mcrypt_encrypt( MCRYPT_RIJNDAEL_128, $this->secret_key, $str, MCRYPT_MODE_CBC, $this->iv );
$encrypted = base64_encode( $encrypted );

The iOS encryption is attached in this file:

StringEncryption.m: http://pastie.org/1365766

I hope someone can help me spot where I’m missing something or have some different parameters of values. I have looked at this for several hours, and can’t find anything else to try.

  • 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-05-18T12:36:29+00:00Added an answer on May 18, 2026 at 12:36 pm

    Most likely it’s a padding issue… Please see here or here for more information.

    EDIT after OP comment:

    PHP has no built-in support for other padding modes than the NULL-padding. At least .Net allows you to specify NULL-padding (I think), the other option would be to implement PKCS#7-padding in PHP which is not that difficult to do.

    Pad the input with a padding string of
    between 1 and 8 bytes to make the
    total length an exact multiple of 8
    bytes. The value of each byte of the
    padding string is set to the number of
    bytes added – i.e. 8 bytes of value
    0x08, 7 bytes of value 0x07, …, 2
    bytes of 0x02, or one byte of value
    0x01.

    $blockSize = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
    $padding   = $blockSize - (strlen($data) % $blockSize);
    $data      .= str_repeat(chr($padding), $padding);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an issue in iOS with a HTML5 Offline app. My app works
I have an issue that is driving me a bit nuts: Using a UserProfileManager
We have an issue using the PEAR libraries on Windows from PHP . Pear
I have a dotnet process that through calls to an unmanaged dll is communicating
I have two applications communicating via RMI, a slave server (of which there will
We have an issue related to a Java application running under a (rather old)
We have an issue on our page whereby the first time a button posts
I have some issue with a Perl script. It modifies the content of a
I have an issue with using AWK to simply remove a field from a
I have big issue with url-rewriting for IIS 7.0. I've written simple module for

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.