SHA1FINAL

Uses a token initialized by the corresponding SHA1INIT function to complete a SHA-1 hash of a series of texts and returns a CHAR(20) string with that hash value.

Read syntax diagramSkip visual syntax diagramSHA1FINAL( t, p, n)
t
A token returned by a previous invocation of SHA1INIT or SHA1UPDATE.
p
A pointer that specifies the address of a buffer to be added to the hash.
n
An expression that specifies the length (in bytes) of that buffer. It must have a computational type and will be converted to type size_t.

SHA1FINAL returns a CHAR(20) value.

This function generates code that executes the KIMD and KLMD assembler instructions.

Examples

The following example performs a SHA-1 hash of a file that is read one line at a time into a CHARACTER variable c.

        dcl token     pointer;
        dcl encoded   char(20);
        token = sha1init();
        on endfile(input);
        do loop;
          read file(input) into(c);
          if endfile(input) then leave;
          token = sha1update(token, addrdata(c), length(c));
        end;
        encoded = sha1final(token, sysnull(), 0);

In the example, all the SHA function calls are in the same block of code. This is not necessary: the calls can occur in a set of routines as long as they all use the same token created by the SHA1INIT call.