Encoding password field with md5 hash

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brewster
    New Member
    • Sep 2007
    • 2

    Encoding password field with md5 hash

    I would like to transfer data from an imported users and passwords table to my main users and passwords table.

    The imported table shows the password field as plain text. I want to transfer this data into the main table and encode the password as an MD5 hash at the same time. Is there a way to do this?

    Other fields / data I need to transfer at the same time are 'username', 'name', 'address', 'city', 'state'. These I want to keep as plain text and not MD5.
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Brewster. Welcome to TSDN!

    You'll want to use MySQL's MD5() function.

    Comment

    • brewster
      New Member
      • Sep 2007
      • 2

      #3
      I am wondering if you could give me an example of some code. thanks.

      Comment

      • mwasif
        Recognized Expert Contributor
        • Jul 2006
        • 802

        #4
        You can INSERT ... SELECT to select data from one table and insert into main table. When selecting data from imported table use MD5() to hash the passwords.e.g.
        [CODE=mysql]INSERT INTO main_table (username, password, name, address, city, state)
        SELECT username, MD5(password), name, address, city, state FROM imported_table;[/CODE]

        Comment

        Working...