sha512(8) DB2 User Defined Function and Stored Procedure sha512(8)
NAME
sha512 - DB2 UDF and SP to generate an SHA512 hash
SYNOPSIS
>>-SHA512--(--expression--+---------+--)----------------------->< '-,--salt-' >>-SHA512--(--expression--+---------+--,--hash--)-------------->< '-,--salt-'
DESCRIPTION
SHA512 algorithm. The sha512 routine returns a glibc2's crypt hash. If the system's crypt does not support sha-512, an SQLSTATE 39702 is returned. The argument can be a character string that is either a CHAR or VARCHAR not exceeding 4096 bytes. An optional salt can be specified, which must be a eight-character string chosen from the set [a-zA-Z0-9./]. If the salt is not exactly eight characters long, an SQLSTATE 39703 is returned. If the salt contains invalid characters, an SQLSTATE 39704 is returned. The result of the function is CHAR(98). The result can be null; if one the arguments is null, the result is the null value.
EXAMPLES
Example 1: Inserting the user test and the sha512 crypted clear text testpwd to the table users. INSERT INTO USERS (username, password) VALUES ('test', sha512('testpwd')) Example 2: SELECT sha512('testpwd') FROM SYSIBM.SYSDUMMY1 1 -------------------------------------------------------------------------------------------------- $6$cD33haq7$dl.RqEaLamlesTPVzSIQr4N1MY3BsVZ76VS8qNte0IOIWO2XorMg8U797KKOFGmX8dJhT3WuF6p17HmvvoQ6Q/ 1 record(s) selected. Example 3: CALL sha512('testpwd', ?) Value of output parameters -------------------------- Parameter Name : HASH Parameter Value : $6$1W.m9JN1$Dh.VPl7vy.igGaeDUdDWw6ZlD0xufwDWm0ukpOYknPtdjxiSM2yzWBkzHffalb/2axNHPqEi9UUzXUbSm4LGa/ Return Status = 0 Example 4: SELECT sha512('testpwd', '12345678') FROM SYSIBM.SYSDUMMY1 1 -------------------------------------------------------------------------------------------------- $6$12345678$tlHrypdWTz6FqubBpgL/ePlxr4lZuQ8OK1zfV6zWUmGJSz.5kGWwQGjg69Qm1Bm3.DvILruqA61o3EHsxSoko1 1 record(s) selected. Example 5: CALL sha512('testpwd', '12345678', ?) Value of output parameters -------------------------- Parameter Name : HASH Parameter Value : $6$12345678$tlHrypdWTz6FqubBpgL/ePlxr4lZuQ8OK1zfV6zWUmGJSz.5kGWwQGjg69Qm1Bm3.DvILruqA61o3EHsxSoko1 Return Status = 0 AUTHOR
Written by Helmut K. C. Tessarek.
BUGS
Hopefully none :-) But if you find one, please report it at: https://github.com/tessus/db2-hash-routines/issues
WEB SITE
http://tessus.github.io/db2-hash-routines sha512 May 2017 sha512(8)