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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:22:37+00:00 2026-06-09T02:22:37+00:00

I have copied source from the answer of this question and have created this

  • 0

I have copied source from the answer of this question

and have created this two functions

function my_encrypt($string) {
    $key="1234";
    return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), 
        $string, MCRYPT_MODE_CBC, md5(md5($key))));
}

function my_decrypt($string) {
    $key="1234";
    return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), 
         base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
}

And when I tried to encrypt and decrypt using the code shown below

 $string="445676467";
    echo $ecr=my_encrypt($string)."<br/>";
    echo my_decrypt($ecr);

The following output is produced

01pEoOCsp7oloZTDMAKF/cxgB0YQFScje6Z8GBXu8Tw=

445676467›HŽÇeVJMç>ÑÑBHc.–ãyeÇN–=“VSã

Wrong with this is that decrypt is not giving correct ouput which is 445676467

but when I tried directly this

$key="1234";
    $string="2011";
    $encrypted= base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, 
        md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));

    $decypted= rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), 
        base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
    echo $encrypted."<br/>";
    echo $decypted;

this gives the correct answer

  • 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-09T02:22:39+00:00Added an answer on June 9, 2026 at 2:22 am

    It’s funny but the reason is your syntex.

    I used your code:

         $string="445676467";
    //You echo & put value in the var at the same time?? smells like troubles.
            echo $ecr=my_encrypt($string)."<br/>"; 
            echo my_decrypt($ecr);
    

    Result:

    01pEoOCsp7oloZTDMAKF/cxgB0YQFScje6Z8GBXu8Tw=
    445676467�H���eVJM�>��BHc.��ye�N�=�VS�
    

    And tried:

     $string="445676467";
        $ecr=my_encrypt($string);
        echo $ecr;
        echo my_decrypt($ecr);
    

    Result:

    01pEoOCsp7oloZTDMAKF/cxgB0YQFScje6Z8GBXu8Tw=
    445676467
    

    Therefore , nothing wrong with your functions , just the usage.
    First put the value in the variable and only then print it.

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

Sidebar

Related Questions

This question is based off of the same app/source from my previous question which
I created a new xna 3.1 project, and copied some source code from a
I have copied class from net which inherits UIImageView. How to put that class
I have copied some files from project A to project B, both of which
I have copied zipped file from the playframework.org website and unzipped it at a
I have copied a project from my old XP machine to my new Win7
why do I get this exception?please suggest any solutions.i have properly copied mail.jar and
I have tried searching for an answer to this, so far I have had
I have copied my home folder from a Mac OSX 10.5 to a new
Very simplified, I have two tables Source and Target. declare @Source table (SourceID int

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.