Blog > April 2010

New Website for Bootheel Tractor Parts

April 2010

We recently launched a completely overhauled website for Bootheel Tractor Parts.  Stealth Creative handled the entire design while we developed a new custom back-end.  The administrative control panel allows BTP to manage their online inventory, newsletters, customer quotes, equipment directory and much more.  Stealth Creative did a great job with creating a new and fresh design for Bootheel and they were a pleasure to work with.  We designed and developed the original Bootheel Tractor Parts website in 2006, but it was time for a new look and overhauled administrative area.

Click here to visit this website





How to Use MySQL's AES_ENCRYPT and AES_DECRYPT to Store Information in a Database

April 2010 · 27 Comments

 

UPDATE (March 2013) - Here's a better solution to storing passwords in a database using PHP/MySQL.

 
This mini-tutorial assumes you already know how to connect to your database and work with php/mysql.  

The benefit of using AES_ENCRYPT and AES_DECRYPT is that you can both encrypt the information, then decrypt whenever necessary.  This is helpful if you're encrypting account information that you need to display. 

View the code here.

1:  The Key
For this to work, you must define a "key" to use when encrypting and decrypting information from the database.  It would be best to store this key somewhere on your server outside of the main directory in which you're working.  This key can be whatever you want it to be, but you must also reference the same key during encrypting and decryption.

$key = 'ASKSDFNSDFKEISDJAHDLDSDF1235UUUiidfsdf';

2:  Encrypt

mysql_query("INSERT INTO users (user_first, user_last, user_password) VALUES ('".$_POST['first']."','".$_POST['last']."',AES_ENCRYPT($_POST['password'],$key))");

3:  Decrypt
Now, to display the decrypted information, you'll need a query similar to the one below:

$field = mysql_fetch_row(mysql_query("SELECT AES_DECRYPT(user_info,'$key') FROM users WHERE user_id = 4"));
echo $field[0];

So, using AES_ENCRYPT and AES_DECRYPT can be very useful when you need to store encrypted information in a database as well as display the original, unencrypted information.  Remember, you must use a 'key' in order to "unlock" and display the encrypted information.