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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 508k
  • Answers 508k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In Erlang, processes are not real processes. They are light… May 16, 2026 at 4:23 pm
  • Editorial Team
    Editorial Team added an answer Currently there is a lot of options to generate dynamic… May 16, 2026 at 4:23 pm
  • Editorial Team
    Editorial Team added an answer Yes you can, as long as you give the outer… May 16, 2026 at 4:23 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a query string I need to encrypt using AES in CBC mode
For a project I'm working on, I need to encrypt and decrypt a string
I need to encrypt a string on the iPhone and send it to a
I want to encrypt a string using AES with my own key. But I'm
we need to encrypt the emails that contain PDFs that are coming from our
I've got a bunch of 48-bit (6 byte) values that I need to encrypt
The situation I'm trying to solve: in my Cocoa app, I need to encrypt
I am using AES 256 to encrypt/decrypt some plain text. But the algorithm uses
I'm in a situation where I need to encrypt / decrypt a file of
i need to encrypt some data but i guess mcrypt library is not native

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.