1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
.TH GOLF 2gg $VERSION $DATE Development Tools
.SH NAME
hmac-string \- (encryption)
.SH PURPOSE
Create HMAC.
.SH SYNTAX
.RS 4
.EX
hmac-string <string> to <result> \\
key <key> \\
[ binary [ <binary> ] \\
[ digest <digest algorithm> ]
.EE
.RE
.SH DESCRIPTION
hmac-string produces by default a SHA256-based HMAC (Hash Message Authentication Code) of <string> (if "digest" clause is not used) using secret <key>, 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:
.RS 4
.EX
\[char35]get digests
openssl list -digest-algorithms
.EE
.RE
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 HMAC is converted to two hexadecimal characters ("0"-"9" and "a"-"f"), hence <result> is twice as long as with "binary" clause.
.SH EXAMPLES
String "result" will have a HMAC value of a given string, an example of which might look like "2d948cc89148ef96fa4f1876e74af4ce984423d355beb12f7fdba5383143bee0"
.RS 4
.EX
hmac-string "some data" key "mykey" to result
.EE
.RE
Using a different digest:
.RS 4
.EX
hmac-string "some data" key "mykey" to result digest "sha3-384"
.EE
.RE
Producing a binary value instead of a null-terminated hexadecimal string, and then making a Base64 string out of it:
.RS 4
.EX
hmac-string "some data" key "mykey" digest "SHA256" to result binary
encode-base64 result to bresult
.EE
.RE
.SH SEE ALSO
Encryption
\fBdecrypt-data\fP
\fBderive-key\fP
\fBencrypt-data\fP
\fBhash-string\fP
\fBhmac-string\fP
\fBrandom-crypto\fP
\fBrandom-string\fP
See all
\fBdocumentation\fP
|