How can we encrypt and decrypt a data presented in a table using MySQL?

Discussion in 'Website Development & Design' started by beingchinmay, Aug 17, 2015.

  1. beingchinmay

    beingchinmay
    uix_expand uix_collapse
    New Member

    Joined:
    Aug 4, 2015
    Messages:
    10
    Likes Received:
    1
    You can use functions: AES_ENCRYPT() and AES_DECRYPT() like:

     
  2. Alan Ron

    Alan Ron
    uix_expand uix_collapse
    Member

    Joined:
    Jul 29, 2015
    Messages:
    83
    Likes Received:
    7
    You can use the following functions to encrypt and decrypt the information from MYSQL table.

    1. AES_ENCRYPT ()
    2. AES_DECRYPT()

    Example:

    insert into UserInfo.login (id, username, password ) values (001, '12',AES_ENCRYPT ('AlanRon','98765'));

    Select AES_DECRYPT(Userinfo.login.password, '98765') from login where id=001;

    You will get output as : AlanRon
     
  3. CashAware

    CashAware
    uix_expand uix_collapse
    Member

    Joined:
    Aug 25, 2015
    Messages:
    31
    Likes Received:
    1
    Duuh. They included that straight into MySQL? SQL engines does so much things these days that I start to see why it clashes so often with NoSQL.

    Well, the thing is, with AES, I guess it is way more safer to encrypt with hexadecimal key, meaning the key can be any value, instead of binding it to the alphebetical values, which isn't 128 bytes even with a 128 character key. The official doc talks about UNHEX function to use hexadecimal instead of a typical string. But anyway, generally, any password should go through a process before being a key, instead of giving it straight to MySQL.
     

Share This Page