Hashes, salts, Doctrine and "binary" types
Posted: Mon Feb 23, 2009 6:41 pm
I recently learned a hard lesson trying to migrate a vBulletin user table into a new application. vBulletin uses salts for passwords. The vBulletin user table was all in latin1 and the app I was moving to was utf8.
Now, vBulletin salt column was (stupidly!!) a char(3) even though the data in it was basically:
To me, this should never have been char(3) and it should have been binary(3). It's not character data it's just 3 random bytes.
This caused loads of problems when moving the data to a utf8 table since MySQL tried to transcode some of the salts which meant they no longer worked with the hashes.
So now I'm trying to set up a schema in Doctrine that needs to use salts...
Is it just me or is the only binary column type doctrine supports "blob" ? That's hella overkill for a 3 byte salt. I may resort to using an ascii-only salt or base64 encoding it if Doctrine can't do small binary types.
Now, vBulletin salt column was (stupidly!!) a char(3) even though the data in it was basically:
Code: Select all
pack('C*', rand(0, 255), rand(0, 255), rand(0, 255));This caused loads of problems when moving the data to a utf8 table since MySQL tried to transcode some of the salts which meant they no longer worked with the hashes.
So now I'm trying to set up a schema in Doctrine that needs to use salts...
Is it just me or is the only binary column type doctrine supports "blob" ? That's hella overkill for a 3 byte salt. I may resort to using an ascii-only salt or base64 encoding it if Doctrine can't do small binary types.