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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:59:28+00:00 2026-05-25T15:59:28+00:00

I have a client/server application that runs on an intranet, and I have the

  • 0

I have a client/server application that runs on an intranet, and I have the requirement to encrypt the data in one field of one table of the database. That field is currently TEXT data type, which I have learned is not good for encryption in MySQL. The text stored in the field is similar to an employee performance evaluation containing narrative comments from supervisors. Because of personal information restrictions concerning the network the system runs on, this data cannot be stored in plain text. The data also needs to editable by different users with differ “roles” (authentication levels) via the client side of the application.

So… I have been researching how to encrypt this data, and this is what I understand so far:

  • MySQL docs explain the AES functions, and that I should change the field datatype likely to a BLOB to accomodate the encrypted information.
  • The key will have to be fixed (i.e. not salted with a user password etc. as I have read on SO), because different users need to be able to edit/review the comments.
  • I think the best option is to store the key and pass it as a variable in the php code, similar to what I do with the MySQL login information for the application.

Is using the AES functions in this scenario a suitable way to proceed with this, or are there issues I don’t know about? I did wonder about problems (performance?) because of the potential length of the text. Most examples I have found relate to encrypting smaller data: e.g. name, address, credit card numbers, etc.

Any advice would be greatly appreciated. Thanks in advance!

  • 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-05-25T15:59:28+00:00Added an answer on May 25, 2026 at 3:59 pm

    Security of the DB

    First you need to ask yourself: “why are you encrypting the data in the database?”.
    The reason is that the database might fall into the wrong hands.
    For this reason you cannot store the key in the database itself.
    You must assume that all data in the DB is known to an attacker.

    Therefore the only answer is to have the key outside the DB.
    I would advise to salt the key using data in the same row as the article, so that an attacker cannot use a rainbow table against all articles.

    pseudocode for select statement:
    
    SELECT AES_DECRYPT(article, CONCAT(salt, '$secret_key')) FROM articles
    WHERE id = '123' 
    

    PHP security
    Note that listing the AES encryption key in the PHP source code will also be a fail.
    It will have to only live in memory on the computer which also needs to be secure.
    An option is to read it in from a remote computer (make the transfer encrypted) that is secure (datacenter with guards) or have a senior official key it in upon program startup.

    How to avoid the MySQL ECB hole
    If you need to have it really secure, you will have to do the encryption in php.

    See this article to know why MySQL (which uses ECB mode) has a problem: http://en.wikipedia.org/wiki/Block_cipher_modes_of_operation#Electronic_codebook_.28ECB.29

    pseudocode

    <?pseudophp
    $secretmessage = $_GET['secret_message_from_user'];
    $randomprefix = hash('sha512',$timestampinmilliseconds);
    $secretmessage = $randomprefix."@@@@".$secretmessage; 
    //$password = "really long password entered by a trusted superuser";
    $key256 = hash('sha512',$password); //stuff the password into 256 bits.
    //You'll have to check that the output is really 256 bits, an tweak it if not.
    $iv =  '1234567890123456'; //this is public, because the iv is already in the text.
    
    printf("iv: %s\n",bin2hex($iv));
    printf("key256: %s\n",bin2hex($key256)); //debug stuff
    printf("message before\n %s\n",$secretmessage);
    
    //We use AES aka RIJNDAEL.
    $cipher = mcrypt_module_open(MCRYPT_RIJNDAEL_256, '', MCRYPT_MODE_CBC, '');
    if (mcrypt_generic_init($cipher, $key256, $iv) != -1)
    {
      // PHP pads with NULL bytes if $cleartext is not a multiple of the block size..
      $cipherText = mcrypt_generic($cipher,$cleartext );
      mcrypt_generic_deinit($cipher);
      // Display the result in hex.
      printf("256-bit encrypted result:\n%s\n\n",bin2hex($cipherText));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a server - client application that runs on java 1.3; i want
I have an application that runs on a client's server built on a SQL
i have a client that runs a windows application on a sql server 2000
I have an application that runs fine when executed off the server. When clients
I have a client/server application that communicates with .Net remoting. I need my clients
I have a client server application that sends XML over TCP/IP from client to
I have a client-server application that uses .net remoting. The clients are in a
I have a client-server application that utilises MSMQ and NServiceBus for messaging. During some
I have a client server based windows forms application that needs an administrator only
I have a server application that receives some special TCP packet from a client

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.