What field type should be used for passwords in MySQL when using PHP crypt() [duplicate]

StackOverflow https://stackoverflow.com/questions/23435929

  •  14-07-2023
  •  | 
  •  

Question

Using PHP crypt() method I have a PHP script to store users encrypted passwords in MySQL database. What field type should I use to store the encrypted data?

Was it helpful?

Solution

varchar(of sufficient length)

OTHER TIPS

Use 'varchar'

In additon to wallyk's answer,
Exact lengths of encrytpted strings using crypt() are;

Standard DES: stqAdD7zlbByI
Extended DES: _S4..someQXidlBpTUu6
MD5: $1$somethin$4NZKrUlY6r7K7.rdEOZ0w.
Blowfish: $2a$09$anexamplestringforsaleLouKejcjRlExmf1671qw3Khl49R3dfu
SHA-256: $5$rounds=5000$anexamplestringf$KIrctqsxo2wrPg5Ag/hs4jTi4PmoNKQUGWFXlVy9vu9
SHA-512: $6$rounds=5000$anexamplestringf$Oo0skOAdUFXkQxJpwzO05wgRHG0dhuaPBaOU/
         oNbGpCEKlf/7oVM5wn6AN0w2vwUgA0O24oLzGQpp1XKI6LLQ0. 

It depends on what type of encryption you are using but varbinary is appropriate in some situations.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top