List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:December 30 2002 5:09am
Subject:Re: Storing a SHA1 checksum
View as plain text  
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?

>
>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.

Thread
Storing a SHA1 checksumPhilip Mak29 Dec
  • Re: Storing a SHA1 checksumBenjamin Pflugmann29 Dec
    • RE: Storing a SHA1 checksumAdolfo Bello29 Dec
  • Re: Storing a SHA1 checksumiConnect \(Berlin\) Stefan Hinz29 Dec
  • Fatal errorPikasz Gyorgy29 Dec
    • Re: Fatal errorDoug Thompson29 Dec
      • Re: Fatal erroriConnect \(Berlin\) Stefan Hinz29 Dec
  • Re: Fatal errorLeVar Bery29 Dec
  • Re: Storing a SHA1 checksumPaul DuBois30 Dec
    • Re: Storing a SHA1 checksumPhilip Mak30 Dec
      • Re: Storing a SHA1 checksumPaul DuBois30 Dec