Hello Ramesh You can do this like This is your string to encrypt and decrypt the data. $key = 'test123'; To insert data in table $query = "INSERT INTO users (UserID, Password) VALUES (1, AES_ENCRYPT('password', '$key')"; To retrieve data from table $query = "SELECT AES_DECRYPT(Password,'$key') AS Password FROM users WHERE UserID = 1"; I hope this will help you. Regards Younas Aamir
If you want something independent of the database, check out phpseclib - http://phpseclib.sourceforge.net/