Using CHAR data type to store passwords

Discussion in 'Databases' started by Stefany93, Aug 22, 2012.

  1. #1
    Dear friends,

    I read in a book that every time you have to store data that you are certain it will be a certain amount of chars, use CHAR data type instead of VARCHAR since it is a lot faster. So I was wondering, since I will be using a hashing algoritam to hash all my password I will be storing in a DB, and since there will ALWAYS be 40 chars why not use the CHAR data type?

    The only thing that is stopping me from doing it is that I see a lot of tutorials where they show people to store the password only with the VARCHAR data type, so I was wondering, what is your opinion on that matter?

    Thank you!

    Best Regards
    Stefany
     
    Solved! View solution.
    Stefany93, Aug 22, 2012 IP
  2. #2
    If you know that the size will always be EXACTLY the same then you can use CHAR, it will be faster...I guess because not everyone will hash the passwords then yes they will have to use varchar, but in your case don't worry about it and just use CHAR(40)
     
    WeddiGo, Sep 22, 2012 IP
  3. Stefany93

    Stefany93 Greenhorn

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    ^^ Thank you WeddiGo, much appreciated.
     
    Stefany93, Sep 22, 2012 IP