sha256(8)       DB2 User Defined Function and Stored Procedure       sha256(8)




NAME

       sha256 - DB2 UDF and SP to generate an SHA256 hash


SYNOPSIS

       >>-SHA256--(--expression--+---------+--)-----------------------><
                                 '-,--salt-'

       >>-SHA256--(--expression--+---------+--,--hash--)--------------><
                                 '-,--salt-'


DESCRIPTION

       SHA256  algorithm. The sha256 routine returns a glibc2's crypt hash. If
       the system's crypt does not  support  sha-256,  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(55). The result can be null; if  one
       of the arguments is null, the result is the null value.


EXAMPLES

       Example 1:

       Inserting  the  user  test and the sha256 crypted clear text testpwd to
       the table users.

       INSERT INTO USERS (username, password)
         VALUES ('test', sha256('testpwd'))

       Example 2:

       SELECT sha256('testpwd') FROM SYSIBM.SYSDUMMY1

       1
       -------------------------------------------------------
       $5$S.LqPR7Z$273zPncMdmJ0dE1WdLldWVBmaHSDUDl8/tW8At8Hc0A

         1 record(s) selected.

       Example 3:

       CALL sha256('testpwd', ?)

         Value of output parameters
         --------------------------
         Parameter Name  : HASH
         Parameter Value : $5$vSDCZr2d$rfh.aDopE5l3lm26AwwcIYnuVdV7/9QBACWukqYyV3/

         Return Status = 0

       Example 4:

       SELECT sha256('testpwd', '12345678') FROM SYSIBM.SYSDUMMY1

       1
       -------------------------------------------------------
       $5$12345678$.oVAnOr/.FK8fYNiFPvoXPQvEOT9Calecygw6K9wIb9

         1 record(s) selected.

       Example 5:

       CALL sha256('testpwd', '12345678', ?)

         Value of output parameters
         --------------------------
         Parameter Name  : HASH
         Parameter Value : $5$12345678$.oVAnOr/.FK8fYNiFPvoXPQvEOT9Calecygw6K9wIb9

         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



sha256                             May 2017                          sha256(8)