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. I ended up using a TINYBLOB to store my checksum, since performance shouldn't be overly critical in my application. --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php