Decodes base64 text.
Decodes base64 text.
(decode-base64 s target)Decodes standard base64. target is :bytes, :string, or :key.
:string decodes as UTF-8; :key builds an HmacSHA256 SecretKeySpec.
Decodes standard base64. `target` is :bytes, :string, or :key. :string decodes as UTF-8; :key builds an HmacSHA256 SecretKeySpec.
(decode-base64-url s)(decode-base64-url s target)Decodes URL-safe base64.
The one-arity returns a String for String input and a byte array for
byte-array input. target is :bytes, :string, or :key; :string decodes
as UTF-8 and :key builds an HmacSHA256 SecretKeySpec.
Decodes URL-safe base64. The one-arity returns a String for String input and a byte array for byte-array input. `target` is :bytes, :string, or :key; :string decodes as UTF-8 and :key builds an HmacSHA256 SecretKeySpec.
Encodes values as base64 text.
Encodes values as base64 text.
(encode-base64 x)Returns standard base64 with padding.
Returns standard base64 with padding.
(encode-base64-url x)Returns URL-safe base64 with padding.
Returns URL-safe base64 with padding.
(encode-base64-url-without-padding x)Returns URL-safe base64 without padding.
Returns URL-safe base64 without padding.
(encode-base64-without-padding x)Returns standard base64 without padding.
Returns standard base64 without padding.
(generate-symmetric-key)Generates a new random HmacSHA256 key using the JCA default key size.
Generates a new random HmacSHA256 key using the JCA default key size.
(hash-dgst bytes)(hash-dgst s algo)Single arity returns the raw SHA-256 digest, suitable for a PKCE code challenge.
The 2-arity is legacy: it uses the platform default charset, drops leading zero
bytes via BigInteger, and pads to only 32 characters, so its output is not
fixed-width for SHA-224/SHA-256/etc. Prefer hash-digest-hex for new code.
Single arity returns the raw SHA-256 digest, suitable for a PKCE code challenge. The 2-arity is legacy: it uses the platform default charset, drops leading zero bytes via BigInteger, and pads to only 32 characters, so its output is not fixed-width for SHA-224/SHA-256/etc. Prefer `hash-digest-hex` for new code.
(hash-digest-hex bytes)(hash-digest-hex s algo)Returns the lowercase hex digest of s using algo (e.g. "SHA-256"),
zero-padded to twice the digest length.
The one-arity accepts a byte array and uses SHA-256. The two-arity accepts a String (encoded as UTF-8) or a byte array, with an explicit algorithm.
Returns the lowercase hex digest of `s` using `algo` (e.g. "SHA-256"), zero-padded to twice the digest length. The one-arity accepts a byte array and uses SHA-256. The two-arity accepts a String (encoded as UTF-8) or a byte array, with an explicit algorithm.
Computes HMAC-SHA256 signatures. The key argument may be a String,
a javax.crypto.spec.SecretKeySpec, or a byte array.
Computes HMAC-SHA256 signatures. The `key` argument may be a String, a javax.crypto.spec.SecretKeySpec, or a byte array.
(sign key data)Returns the HMAC-SHA256 of data as a lowercase hex string.
Returns the HMAC-SHA256 of `data` as a lowercase hex string.
(sign-bytes key data)Returns the HMAC-SHA256 of data as a byte array.
Returns the HMAC-SHA256 of `data` as a byte array.
(verify-hmac key data hmac)Verifies a hex hmac against the HMAC-SHA256 of data under key.
Compares the UTF-8 bytes of both hex strings with MessageDigest/isEqual, so the running time does not depend on where they first differ. Returns true when the values match, false otherwise.
Verifies a hex `hmac` against the HMAC-SHA256 of `data` under `key`. Compares the UTF-8 bytes of both hex strings with MessageDigest/isEqual, so the running time does not depend on where they first differ. Returns true when the values match, false otherwise.
(verify-hmac-bytes key data hmac)Verifies a raw hmac against the HMAC-SHA256 of data under key.
hmac may be a byte array or any seqable collection of byte values.
Byte arrays and normalized collections are compared in constant time.
Non-integers and values outside the signed-byte range never match.
Returns true when the values match, false otherwise.
Verifies a raw `hmac` against the HMAC-SHA256 of `data` under `key`. `hmac` may be a byte array or any seqable collection of byte values. Byte arrays and normalized collections are compared in constant time. Non-integers and values outside the signed-byte range never match. Returns true when the values match, false otherwise.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |