Thursday, February 23, 2023

Data Encryption and Decryption in MySQL (Command Line)


            Data encryption and decryption are important techniques used in information security to protect sensitive information from unauthorized access. MySQL 8.0 provides several encryption functions that can be used to encrypt and decrypt data.

In this blog post, we will discuss how to use MySQL 8.0 command line to encrypt and decrypt data.

Encrypting Data:

MySQL 8.0 provides several encryption functions that can be used to encrypt data. The most commonly used encryption functions are AES_ENCRYPT and SHA2. AES_ENCRYPT is an encryption function that uses the Advanced Encryption Standard (AES) algorithm to encrypt data. SHA2 is a cryptographic hash function that can be used for encryption.

Here is how you can use these functions to encrypt and decrypt data in MySQL 8.0:

 1.Open the MySQL command line interface.

 2.Select the database you want to use by typing "USE database_name;".

 For example:


3.Create a table to store the encrypted data. 

 For example:


4.Insert data into the table and encrypt it using the AES_ENCRYPT function. 

 For example:


           Replace "my_key" with your own encryption key.

Decrypting Data:

 5.Query the encrypted data using the AES_DECRYPT function to decrypt it.

 For example:



 6.To UPDATE encrypted data, use the AES_ENCRYPT function again. 

 For example:


      Updated value:


7.To delete encrypted data, use the DELETE command. 

 For example:

      Before deletion:


      After Deletion:



Thank you,

Venkata kishore T(Intern)
Shield Strategists,
Data Shield Team,
Enterprise Minds.


EM-Tirupati Codeathon Series #08

[Question] ROBOTIC CRICKET MATCH you should write a program that simulate an automatic cricket match between India and Sri Lanka. The fo...