By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,733 Members | 845 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,733 IT Pros & Developers. It's quick & easy.

Mysql Storing Encrypted Data : Data Type And Field Lengths?

P: 10
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


Not sure on data type or field length though. If anyone can offer help I would be grateful
Jan 16 '08 #1
Share this Question
Share on Google+
2 Replies

code green
Expert 100+
P: 1,726
MD5 returns a 16 byte string,
while SHA1 returns a 20 byte string.
Therefore use a VARCHAR(16) or VARCHAR(20).
Jan 16 '08 #2

P: 10
Many Thanks that was just what I was looking for, implimented it and its working great!
Jan 16 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.