Skip to content

Commit 61b6c5c

Browse files
committed
crypto.hmac
1 parent 2b97de1 commit 61b6c5c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

docs/Runtime Environment/Crypto.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,19 @@ local crypto = require("crypto")
265265
print(crypto.ripemd160("Pluto")) --> c2072a85f4a691803b8942709036072086fd9550
266266
```
267267
---
268+
### `crypto.hmac`
269+
Authenticates a message using the HMAC construction with the given hash algorithm.
270+
#### Parameters
271+
1. The hash algorithm to use. `"sha1"`, `"sha256"`, `"sha384"`, or `"sha512"`.
272+
2. The secret key.
273+
3. The message to authenticate.
274+
4. When set to true, returns raw binary data. false outputs lowercase hex digits. By default, this is false.
275+
```pluto
276+
local crypto = require("crypto")
277+
local key = "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b"a
278+
print(crypto.hmac("sha256", key, "Hi There")) --> b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7
279+
```
280+
---
268281
## Cryptographic PRNGs
269282
### `crypto.random`
270283
This is a cryptographically secure PRNG, assuming the platform's implementation of the underlying primitive is secure.

0 commit comments

Comments
 (0)