dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: SQL
Expertise: Intermediate
Jan 21, 2020

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Using COMPRESS in MySQL

There are instances in which we would like to encrypt some text and store it for future reference. It could be some passwords or any other kind of information that may need to be kept secret.

Consider the following query. We are attempting to store the text 'MyName' as encrypted. Of course, we aren't using any encryption mechanisms here, however, we are using the COMPRESS method that comes in handy.

Query:

SELECT COMPRESS('MyName');

This results as below.

+-----------------------------------+
| COMPRESS('MyName')                |
+-----------------------------------+
| \0\0\0x???K?M\0?H   | 
+-----------------------------------+

We can retrieve the text using UNCOMPRESS over the COMPRESS method.

Sridhar MS
 
Thanks for your registration, follow us on our social networks to keep up-to-date