Syntax:
SHA2(str, hash_length)

Calculates the SHA-2 family of hash functions (SHA-224, SHA-256,
SHA-384, and SHA-512). The first argument is the cleartext string to be
hashed. The second argument indicates the desired bit length of the
result, which must have a value of 224, 256, 384, 512, or 0 (which is
equivalent to 256). If either argument is NULL or the hash length is
not one of the permitted values, the return value is NULL. Otherwise,
the function result is a hash value containing the desired number of
bits. See the notes at the beginning of this section about storing hash
values efficiently.

As of MySQL 5.5.6, the return value is a nonbinary string in the
connection character set. Before 5.5.6, the return value is a binary
string; see the notes at the beginning of this section about using the
value as a nonbinary string.

URL: http://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html

