On Sep 17, 2010, at 7:08 AM, Tompkins Neil wrote: > Hi > > Why when I run the command (MySQL 5.1) SELECT SHA1('abc'); is it returned as > a binary value and not a string value ?
If you mean, why is it a binary rather than a nonbinary (character) string, that's true of most of the encryption or compression functions in 5.1. This was changed in 5.5. http://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html says: " Many encryption and compression functions return strings for which the result might contain arbitrary byte values. If you want to store these results, use a column with a VARBINARY or BLOB binary string data type. This will avoid potential problems with trailing space removal or character set conversion that would change data values, such as may occur if you use a nonbinary string data type (CHAR,VARCHAR, TEXT). Some encryption functions return strings of ASCII characters: MD5(), OLD_PASSWORD(), PASSWORD(), SHA(),SHA1(). As of MySQL 5.5.3, their return value is a nonbinary string that has a character set and collation determined by the character_set_connection and collation_connection system variables. Before 5.5.3, these functions return binary strings. The same change was made for SHA2() in MySQL 5.5.6. " -- Paul DuBois Oracle Corporation / MySQL Documentation Team Madison, Wisconsin, USA www.mysql.com -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org