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


advertisement
 

Tip: Using COMPRESS in MySQL

See how to easily encrypt text in MySQL with the compress method.


advertisement

WEBINAR:

On-Demand

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


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.

 

Visit the DevX Tip Bank

 





   
Sridhar M S. is a Java developer from Bangalore, India. He holds a master's degree in Computer Science.
Thanks for your registration, follow us on our social networks to keep up-to-date