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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:46:03+00:00 2026-05-15T19:46:03+00:00

I need to encrypt a string using MySQL’s AES_ENCRYPT function, then attach that encrypted

  • 0

I need to encrypt a string using MySQL’s AES_ENCRYPT function, then attach that encrypted string to the end of a URL, such that it can then be decrypted and used by a PHP script on the other end.

Basically, I am encrypting the string (using MySQL’s AES_ENCRYPT), I am then using PHP’s rawurlencode() function to make it “URL safe”. I then pass the encrypted string in a URL, which is then retrieved by the PHP script on the other end where it gets successfully decrypted… about 95% of the time.

Seems as though about 5% of strings are encrypting in such a way that they are getting corrupted somewhere in the process, and can’t be decoded on the other end after being passed by a URL. Can anyone help me out here? Is there a 100% fool-proof way to do this? I have also tried using urlencode() as well as base64_encode() in varying combinations.

Thanks.

  • 1 1 Answer
  • 1 View
  • 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-15T19:46:04+00:00Added an answer on May 15, 2026 at 7:46 pm

    Solved.

    Once I have encrypted the string using MySQL’s AES_ENCRYPT function, I use PHP’s bin2hex() function to convert that encrypted data (which is in binary form) in to Hexidecimal. I then pass the Hexidecimal as a string on the end of the URL. Once the URL is received on the other end, I then use this custom PHP function to revert the Hex string back to binary:

    function hex2bin($data) {
        $len = strlen($data);
        return pack("H" . $len, $data);
    }
    

    From there, all that’s left to do is decrypt the data using MySQL’s AES_DECRYPT function, and wha-la. The original string is successfully restored.

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

Sidebar

Related Questions

I need to encrypt a column in MySQL and I am using AES_ENCRYPT. I
in function need key to encrypt string without mcrypt libraly in php function encrypt($str,
I have a query string I need to encrypt using AES in CBC mode
Here are my requirements: I need to encrypt a string in PHP using AES
I need to encrypt some text with RSA, and then recover it later using
I need to encrypt a text string in a .net application using a known
I need to encrypt a string using an RSA 1.5 algorithm. I have been
I need to encrypt string in my app using RSA key from file .key.
I need to encrypt a string using a salt and a key to match
I need to encrypt and sign data using PKCS7(CMS) . I am using bouncy

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.