Cifrado en MySQL

Muchas veces queremos guardar datos en una base de datos MySQL de forma cifrada. Una forma muy eficiente es guardando el contenido con un hash tipo md5 o sha-1. Estos dos algoritmos permiten guardar los datos de forma cifrada y muy difícil de recuperar.

Podemos utilizar esta codificación de la siguiente manera (extraido del manual MySQL):

  1. CREATE TABLE md5_tbl (md5_val CHAR(32), ...);
  2. INSERT INTO md5_tbl (md5_val, ...) VALUES(MD5('abcdef'), ...);

El problema que ocurre en este caso es que nosotros tampoco podemos recuperar la información. Esto hace que sea un método muy útil para contraseñas. así la que nos introduce el usuario es cifrada y la podemos comparar con esta.

Recuperando datos cifrados

Puede ocurrir el caso en el que queramos mantener datos cifrados en la base de datos, pero, al mismo tiempo poder recuperarlos. Para ello utilizamos otro tipo de funciones que utilizan una clave externa para realizar la codificación del contenido del campo. Una que nos puede resultar muy útil es AES_ENCRYPT. Esta función nos permite cirar un contenido juntamente con la clave y posteriormente, con AES_DECRYPT y la clave recuperar el valor original.

Un ejemplo puede ser el siguiente:

  1. INSERT INTO t (col1, col2) VALUES (1, AES_ENCRYPT('valor original', 'clave'));
  2. SELECT col1, EAS_DECRYPT(col2, 'clave');

Hemos de tener en cuenta que para utilizar este cifrado la columna la hemos de definir como VARBINARY, y que normalmente con una longitud de 32 suele ser suficiente. En nuestro ejemplo la columna definida como varbinary sería col2.

Eperamos que os sea de utilidad este tipo de cifrado.

Etiquetas: 

Comentarios

Viagra Super Plus Active Lioresal Acheter En Canada buy accutane 30 mg Achat De Viagra En Suisse En Cholet Mixing Amoxicillin Wine Together Propecia Firenze Canadian Medicines Online cialis 5mg best price Prix Du Cytotec Dans Une Pharmacie

Tomar Viagra Zantac Amoxicillin viagra Como Comprar Cialis Isotretinoin 10mg Skin Health Zithromax Erythromycin viagra online Buy Valtrex Without Insurance Cephalexin Lawsuit Trouver Du Cialis Pas Cher viagra Lawrence Walter Pharmacy Canada Isotretinoin Isotrex Cialis Naturale Alle Erbe buy viagra levitra Acheter Cialis Paypal

Kamagra Gold Medicina Cialis Soft cheapest generic levitra Buying Doxycycline Online Uk Safe Buy Dilantin No Script secure ordering isotretinoin pills in internet Daily Cialis Priligyonlineusa Cialis Farmacia Online cialis 5 mg Meprate Propecia Low Risk Of Side Effects Purchase Minocycline 100mg Propecia 100mg viagra Cialis Daily Propecia Merck Serono general pharmacy levitra Cialis 20 Mg Precio Farmacia What Is Amoxicillin Bp Cipla Viagra Products Lowest Price Viagra 100mg Canada 2014 cialis 5mg best price Propecia Hipertension 247overnightpharmacy Scam Viagra Professional 100 Mg Generic

Cialis Inconvenients cialis 5mg Viagra Yahoo Respuestas Propecia Finasteride Acheter Tadalafil 40mg

What's up, I log on to your blog daily. Your story-telling style is
witty, keep doing what you're doing!

Here is my webpage: sex việt nam gái xinh múp nõn

Hi! I've been reading your web site for some

time now and finally got the bravery to go ahead and give you a shout out from Kingwood

Texas! Just wanted to mention keep up the good

work!

My website; Jogue Sweet Bonanza

Hi there this is kinda of off topic but I was wondering if blogs use WYSIWYG editors or if
you have to manually code with HTML. I'm starting a
blog soon but have no coding experience so I wanted to get guidance from
someone with experience. Any help would be enormously appreciated!

Feel free to visit my site - bet88com1.com

I enjoy what you guys are up too. This type of clever work and
coverage! Keep up the wonderful works guys I've incorporated you guys
to my personal blogroll.

Here is my homepage; sex việt nam gái xinh múp nõn

hello there and thank you for your information – I've certainly
picked up something new from right here. I did
however expertise a few technical issues using this
website, as I experienced to reload the web site lots of times previous
to I could get it to load properly. I had been wondering if
your web hosting is OK? Not that I am complaining, but sluggish loading instances times will
very frequently affect your placement in google and could damage your high quality score if ads and marketing with Adwords.

Anyway I'm adding this RSS to my email and could look out for much more of your respective
intriguing content. Make sure you update this again very soon.

Feel free to visit my webpage; sex việt nam gái xinh múp nõn

Thanks for finally talking about > Añadir nuevo comentario | avanzalia.info < Liked it!

Here is my blog: 789p.com

Páginas

Añadir nuevo comentario

Filtered HTML

  • Las direcciones de las páginas web y las de correo se convierten en enlaces automáticamente.
  • Etiquetas HTML permitidas: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Saltos automáticos de líneas y de párrafos.

Plain text

  • No se permiten etiquetas HTML.
  • Las direcciones de las páginas web y las de correo se convierten en enlaces automáticamente.
  • Saltos automáticos de líneas y de párrafos.
CAPTCHA
Esta pregunta se realiza para comprobar que se trata de un humano y prevenir los accesos automatizados para publicar spam.