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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:17:18+00:00 2026-06-09T09:17:18+00:00

I need to encrypt a column in MySQL and I am using AES_ENCRYPT. I

  • 0

I need to encrypt a column in MySQL and I am using AES_ENCRYPT. I want to figure out a safe way to use this data column in a WHERE clause. My question is this –

1) Can I AES_ENCRYPT the WHERE clause argument with the same pass-phrase and use the generated encrypted string in the WHERE clause? Or do I have to run decryption on the whole column?

For example, will this be safe?

SELECT * from TABLE WHERE Enc_COL= AES_ENCRYPT('someColValue','same_passphrase');

or does it have to be

SELECT * from TABLE WHERE AES_ENCRYPT(Enc_COL,'same_passphrase')= 'someColValue';

I believe the second one will be much slower and so, I want to know if the first example is possible.

  • 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-09T09:17:20+00:00Added an answer on June 9, 2026 at 9:17 am

    Using

    SELECT * FROM `table`
    WHERE `Enc_COL` = AES_ENCRYPT('text-to-encrypt', 'same_passphrase');
    

    should be fine. Just make sure there is an index for Enc_Col so you don’t have to scan the entire table for results. As long as you use the same input and key you will get the same output.

    Just a side note, don’t use the same key for more than one column (make sure to use some sort of IV or crytographic nonce that’s unique to each column you encrypt). If you encrypt all of the rows with the same key and your database is compromised, it makes it much more likely that someone can find the key.

    • 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 string using MySQL's AES_ENCRYPT function, then attach that encrypted
I need to encrypt and sign data using PKCS7(CMS) . I am using bouncy
I need encrypt data using exactly the PKCS#1 V2.0 encryption method (defined in item
I need to encrypt some data using RSA in JavaScript. All of the libraries
I need to encrypt a small block of data (16 bytes) using 512 bit
I need to encrypt an image of size 151*15 with RSA. This is the
I need to encrypt & decrypt data with both Java (on Android) and SJCL
I'm developing a Web Site using ASP.NET MVC 3, Nowadays I need to encrypt
I need to encrypt a number and I and this encrypted value will be
I have a query string I need to encrypt using AES in CBC mode

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.