At 0:14 -0500 12/30/02, Philip Mak wrote:
>On Sun, Dec 29, 2002 at 11:09:47PM -0600, Paul DuBois wrote:
>> At 5:28 -0500 12/29/02, Philip Mak wrote:
>> >sql, table
>> >
>> >I'm storing a SHA1 checksum as "varchar(20) binary" in my application.
>>
>> Other people have addressed other aspects of your message, but I'm
>> curious why you're using a VARCHAR(20), when SHA1() returns a 40-byte
>> string.
>> >
>> >After running a test, it seems MySQL will strip trailing spaces from a
>> >varchar column, even if it is binary! That means if the last character
>> >of my SHA1 checksum happens to be a space, MySQL will corrupt it.
>>
>> SHA1() returns a string of 40 hexadecimal digits. There won't be trailing
>> spaces.
>>
>> Are you converting the hex string to some other representation before
>> storing it?
>
>Yes, I'm converting it to a binary representation first, so that it
>only takes 20 bytes instead of 40 bytes.
Okay. I see then why you might end up with trailing 'spaces'.
>
>I ended up using a TINYBLOB to store my checksum, since performance
>shouldn't be overly critical in my application.
Sounds like a good choice.