Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql workbench md5 column - how to?

Does anyone know how/where can we apply to a column, a md5 encryption.

I'm creating a user password table and on the password column I would like to apply md5 encryption.

Thanks in advance.

like image 919
MEM Avatar asked May 01 '11 13:05

MEM


2 Answers

Taken from mysql workbench manual:

It is possible to enter a function, or other expression, into a field. Use the prefix \func to prevent MySQL Workbench from escaping quotation marks. For example, for the expression md5('fred'), MySQL Workbench normally would generate the code md5(\'fred\'). To prevent this, enter the expression as \func md5('fred') to ensure that the quoting is not escaped.

like image 105
Dan Avatar answered Jan 04 '23 05:01

Dan


There's an 'md5()' function that when given a string will return a string of 32 hex digits. Just create a column of char(32) to hold it should do the trick.

See documentation.

In terms of using this within MySql workbench, I don't think it's possible to mark a column to contain an md5 hash explicitly as really you can simply put an md5 hash in a char column as mentioned above. I don't believe that you can have a column implicitly perform the md5 function call on an inserted string in this fashion. (I could be wrong).

like image 44
Phil Street Avatar answered Jan 04 '23 05:01

Phil Street