(b64-std-decode s)Standard base64 (RFC 4648 §4, padded) -> string, or nil when malformed.
Standard base64 (RFC 4648 §4, padded) -> string, or nil when malformed.
(b64url x)base64url without padding (RFC 4648 §5) of byte values or a string.
base64url without padding (RFC 4648 §5) of byte values or a string.
(b64url-decode-vals s)base64url (padding optional) -> unsigned byte values. Throws on a character outside the alphabet.
base64url (padding optional) -> unsigned byte values. Throws on a character outside the alphabet.
(form-encode m)application/x-www-form-urlencoded of a map, keys sorted (deterministic).
application/x-www-form-urlencoded of a map, keys sorted (deterministic).
(hex vs)Lower-case hex of unsigned byte values.
Lower-case hex of unsigned byte values.
(int->vals n)(int->vals n len)A non-negative integer -> big-endian unsigned byte values, left-padded to
len (minimal length when len is nil).
A non-negative integer -> big-endian unsigned byte values, left-padded to `len` (minimal length when `len` is nil).
(jwk->public jwk)A JWK's {"n" "e"} (base64url) -> {:n :e}.
A JWK's {"n" "e"} (base64url) -> {:n :e}.
(mod-pow base e m)base^e mod m (square-and-multiply, left to right).
base^e mod m (square-and-multiply, left to right).
(parse-query q)A query / form string as {name first-value}. Malformed escapes keep the raw text.
A query / form string as {name first-value}. Malformed escapes keep the raw text.
(probable-prime? n rounds)Trial division by the primes below 2000, then rounds Miller-Rabin rounds.
Trial division by the primes below 2000, then `rounds` Miller-Rabin rounds.
(rand-token n)n random url-safe characters (hex) from the host CSPRNG.
n random url-safe characters (hex) from the host CSPRNG.
(rsa-generate)(rsa-generate bits)A fresh RSA key pair: {:n :e :d :p :q :dp :dq :qinv}. bits default 2048.
A fresh RSA key pair: {:n :e :d :p :q :dp :dq :qinv}. `bits` default 2048.
(rsa-jwk {:keys [n e]})The public JWK members {"kty" "n" "e"} of a key.
The public JWK members {"kty" "n" "e"} of a key.
(rsa-sign {:keys [n p q dp dq qinv]} msg)RS256 (RSASSA-PKCS1-v1_5 + SHA-256) of string msg; signature byte values.
NOT constant-time — dev/test keys only (see the namespace comment).
RS256 (RSASSA-PKCS1-v1_5 + SHA-256) of string `msg`; signature byte values. NOT constant-time — dev/test keys only (see the namespace comment).
(rsa-verify? {:keys [n e]} msg sig)True when sig (byte values) is a valid RS256 signature of string msg
under the public key {:n :e}.
True when `sig` (byte values) is a valid RS256 signature of string `msg`
under the public key {:n :e}.(sha256 x)SHA-256 of a string (UTF-8) or a seq of unsigned byte values; 32 unsigned byte values.
SHA-256 of a string (UTF-8) or a seq of unsigned byte values; 32 unsigned byte values.
(url-decode s)(url-decode s plus?)Percent-decode ONCE; plus? also maps + to a space (forms). Throws on a
malformed escape or a result that is not UTF-8.
Percent-decode ONCE; `plus?` also maps `+` to a space (forms). Throws on a malformed escape or a result that is not UTF-8.
(url-encode s)Percent-encode every byte outside RFC 3986's unreserved set (UTF-8).
Percent-encode every byte outside RFC 3986's unreserved set (UTF-8).
(utf8-vals s)A string's UTF-8 bytes as unsigned values (0-255).
A string's UTF-8 bytes as unsigned values (0-255).
(valid-utf8? vs)True when the unsigned byte values are well-formed UTF-8 (RFC 3629: no overlongs, no surrogates, nothing above U+10FFFF).
True when the unsigned byte values are well-formed UTF-8 (RFC 3629: no overlongs, no surrogates, nothing above U+10FFFF).
(vals->int vs)Big-endian unsigned byte values -> a non-negative integer.
Big-endian unsigned byte values -> a non-negative integer.
(vals->utf8 vs)Unsigned byte values back to a string (UTF-8).
Unsigned byte values back to a string (UTF-8).
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 |