A cryptographic hash (sometimes called ‘digest’) is a kind of ‘signature’ for a text or a data file. SHA-512 generates an almost-unique 512-bit (32-byte) signature for a text. See below for the source code.
This is a companion to the SHA-256 script (where there’s more explanation). This is a reference implementation, as close as possible to the NIST specification, to help in understanding the algorithm (§ection numbers relate the code back to sections in the standard); it is not at all optimised (using Chrome on a low-to-middling Core i5 PC, in timing tests this script will hash a short message in around 0.4 – 0.6 ms; longer messages will be hashed at a speed of around 0.5 – 1 MB/sec.
Long library for UInt64 operations; there would be more efficient means of doing
this for an optimised implementation.