hash-string - (encryption)
Contents
Description
hash-string produces by default a SHA256 hash of <string> (if "digest" clause is not used), and stores
the result into <result>. You can use a different <digest algorithm> in "digest" clause (for example
"SHA3-256"). To see a list of available digests:
#get digests
openssl list -digest-algorithms
If "binary" clause is used without boolean variable <binary>, or if <binary> evaluates to true, then the
<result> is a binary string that may contain null-characters. With the default SHA256, it is 32 bytes in
length, while for instance with SHA3-384 it is 48 bytes in length, etc.
Without "binary" clause, or if <binary> evaluates to false, each binary byte of hashed string is
converted to two hexadecimal characters ("0"-"9" and "a"-"f"), hence <result> is twice as long as with
"binary" clause.
Examples
String "result" will have a hashed value of the given string, an example of which might look like
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855":
hash-string "hello world" to hash
Using a different digest:
hash-string "hello world" to hash digest "sha3-384"
Producing a binary value instead of a null-terminated hexadecimal string:
hash-string "hello world" to hash digest "sha3-384" binary
Name
hash-string - (encryption)
Purpose
Hash a string.
See Also
Encryption
decrypt-dataderive-keyencrypt-datahash-stringhmac-stringrandom-cryptorandom-string See all
documentation
$DATE $VERSION GOLF(2gg)
Syntax
hash-string <string> to <result> \
[ binary [ <binary> ] \
[ digest <digest algorithm> ]
