Mysql Storing Encrypted Data : Data Type And Field Lengths?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daknightuk
    New Member
    • Jan 2008
    • 10

    Mysql Storing Encrypted Data : Data Type And Field Lengths?

    I have created a database and I want to add a field to it which will store the password using the php encryption method of MD5 or SHA1

    I just simply need to know what datatype to use in the database for storing this type of information as I dont want data to be rejected or cut off because of field lengths.

    I would expect to encrypt something like "this is test" in PHP and it be stored in the database table like

    fe1ca9859cefff1 9959d57aadc1718 7e

    Not sure on data type or field length though. If anyone can offer help I would be grateful
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    MD5 returns a 16 byte string,
    while SHA1 returns a 20 byte string.
    Therefore use a VARCHAR(16) or VARCHAR(20).

    Comment

    • daknightuk
      New Member
      • Jan 2008
      • 10

      #3
      Many Thanks that was just what I was looking for, implimented it and its working great!

      Comment

      Working...