Tech Tip: Computing a SHA-512 hash in 4D without a plugin or component
PRODUCT: 4D | VERSION: 21 | PLATFORM: Mac & Win
Published On: November 18, 2026
This tech tip shows how to generate SHA-512 hashes natively in 4D. The command Generate Digest can be used with the SHA512 digest constant (value 4). It returns the hash as a 128-character hexadecimal string:
The hash is computed on the UTF-8 representation of the text and gives the same result on macOS and Windows. If the remote service expects Base64URL instead of hexadecimal, pass * as the third parameter:
SHA256 digest (value 3) works the same way for SHA-256 and returns 64 hexadecimal characters.
This approach is for sending a hash to an external system that requires it. To store and check your application’s own user passwords, use Generate password hash and Verify password hash instead, as the documentation recommends.
| var $hash : Text:=Generate digest("MyText"; SHA512 digest) |
The hash is computed on the UTF-8 representation of the text and gives the same result on macOS and Windows. If the remote service expects Base64URL instead of hexadecimal, pass * as the third parameter:
| var $hash : Text:=Generate digest("MyText"; SHA512 digest;*) |
SHA256 digest (value 3) works the same way for SHA-256 and returns 64 hexadecimal characters.
This approach is for sending a hash to an external system that requires it. To store and check your application’s own user passwords, use Generate password hash and Verify password hash instead, as the documentation recommends.