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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:34:29+00:00 2026-06-12T12:34:29+00:00

After a long time searching for the best way to en/decrypt data between PHP

  • 0

After a long time searching for the best way to en/decrypt data between PHP and iOS, I’m now asking you for a function in PHP.

I’m using this framework (https://gist.github.com/2507415) in Objective-C and my code is:

NSString *string= @"Affe";
NSString *key = @"12345678901234567890123456789012";
NSLog(%@,[string AES256EnryptWithKey:key];

Output: UUfn34iyNlSK40VaehloaQ==

I’ve tried so much in PHP but nothing works. I hope somebody knows how to decrypt this server-side.

  • 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-12T12:34:31+00:00Added an answer on June 12, 2026 at 12:34 pm

    That seems to be using AES 128, with no IV in ECB mode and PKCS-7 compatible padding, try this:

    function encrypt($str, $key)
    {
        $block = mcrypt_get_block_size('rijndael-128', 'ecb');
        $pad = $block - (strlen($str) % $block);
        $str .= str_repeat(chr($pad), $pad);
    
        return base64_encode(mcrypt_encrypt('rijndael-128', $key, $str, 'ecb'));
    }
    
    function decrypt($str, $key)
    {   
        $str = mcrypt_decrypt('rijndael-128', $key, base64_decode($str), 'ecb');
    
        $block = mcrypt_get_block_size('rijndael-128', 'ecb');
        $pad = ord($str[($len = strlen($str)) - 1]);
        return substr($str, 0, strlen($str) - $pad);
    }
    

    PS: I had forgotten about the base64 encoding, it’s fixed now.

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

Sidebar

Related Questions

After a long time searching and trying I'm asking now for help: My situation:
After long time of searching the best upload technique I've decided to go with
After searching for a long time for a simple way of changing the text
After searching a long time for a performance bug, I read about denormal floating
I've been using Symfony for a long time but I'm new to Symfony2. After
I received this message after long time of using the same application without programming
For a long time now I have been searching through the forum whilst teaching
This is a stupidly easy question, however after searching for a long time I
After long time of searching I have to give up and ask. Is it
I tried to add JOGL to my project, and after a long time searching

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.