Encryption Function



The MD5 function returns the MD5 128-bit checksum for the input character string. The result value is displayed as a character string that is expressed in 32 hexadecimals, which you can use to create hash keys, for example.

Parameters:string -- Input string. If a value that is not a VARCHAR type is entered, it will be converted to VARCHAR.
Return type:STRING

The return value is a VARCHAR (32) type and if an input parameter is NULL, NULL will be returned.

SELECT MD5('cubrid');
SELECT MD5(255);
SELECT MD5('01/01/2010');
SELECT MD5(CAST('2010-01-01' as DATE));
   md5( cast('2010-01-01' as date))



The SHA1 function calculates an SHA-1 160-bit checksum for the string, as described in RFC 3174 (Secure Hash Algorithm).

Parameters:string -- target string to be encrypted
Return type:STRING

The value is returned as a string of 40 hex digits, or NULL if the argument is NULL.

SELECT SHA1('cubrid');


SHA2(string, hash_length)

The SHA2 function 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).

Parameters:string -- target string to be encrypted
Return type:STRING

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.

SELECT SHA2('cubrid', 256);
   sha2('cubrid', 256)
SELECT SHA2('cubrid', 224);
   sha2('cubrid', 224)