At 5:28 -0500 12/29/02, Philip Mak wrote:
>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
>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
Are you converting the hex string to some other representation before
>What should I do? It seems I can:
>1. Use blob instead of varchar.
> Problem: blob type is slower.
>2. Make my application pad the checksum out to 20 spaces.
> Problem: Increases my code complexity a bit.
>3. Wait for MySQL to fix the strip trailing spaces bug.
> Problem: That doesn't provide an immediate solution.