Liking cljdoc? Tell your friends :D

dk.simongray.webcrypto.bytes

Bytes on both platforms, a byte array on the JVM and a Uint8Array in JavaScript, and their encodings: UTF-8, hex, base64 and base64url.

Each decoder returns nil for text that isn't valid. The decoders of base64 are strict on both platforms: they take only the alphabet, the padding where RFC 4648 asks for it and pad bits of zero, so that no two texts decode to the same bytes.

Bytes on both platforms, a byte array on the JVM and a Uint8Array in
JavaScript, and their encodings: UTF-8, hex, base64 and base64url.

Each decoder returns nil for text that isn't valid. The decoders of
base64 are strict on both platforms: they take only the alphabet, the
padding where RFC 4648 asks for it and pad bits of zero, so that no two
texts decode to the same bytes.
raw docstring

atclj/s

(at b i)

The byte at the index i of b, as a number from 0 to 255.

The byte at the index `i` of `b`, as a number from 0 to 255.
sourceraw docstring

base64clj/s

(base64 b)

The bytes b in base64, with padding.

The bytes `b` in base64, with padding.
sourceraw docstring

base64urlclj/s

(base64url b)
(base64url b {:keys [padding?] :as opts})

The bytes b in base64url, the alphabet of base64 for URLs and file names, with opts:

  • :padding?, true to pad the text to a multiple of four characters, as base64 is. It's false by default, as in JOSE and most other uses.
The bytes `b` in base64url, the alphabet of base64 for URLs and file
names, with `opts`:

- :padding?, true to pad the text to a multiple of four characters, as
  base64 is. It's false by default, as in JOSE and most other uses.
sourceraw docstring

bytes?clj/s

(bytes? x)

Whether x is bytes: a byte array on the JVM, or a Uint8Array in JavaScript (and a Buffer in Node is one).

Whether `x` is bytes: a byte array on the JVM, or a Uint8Array in
JavaScript (and a Buffer in Node is one).
sourceraw docstring

concatclj/s

(concat & bs)

The bytes of each of bs, one after another, as new bytes.

The bytes of each of `bs`, one after another, as new bytes.
sourceraw docstring

decodeclj/s

(decode b)

The text of the UTF-8 bytes b. A byte order mark stays, and bytes that aren't UTF-8 become U+FFFD, though the JVM and JavaScript can differ in how many.

The text of the UTF-8 bytes `b`. A byte order mark stays, and bytes that
aren't UTF-8 become U+FFFD, though the JVM and JavaScript can differ in
how many.
sourceraw docstring

encodeclj/s

(encode s)

The bytes of the text s in UTF-8, or a throw of type-error when s isn't a string. A lone surrogate, which UTF-8 can't hold, becomes U+FFFD on both platforms, as with TextEncoder.

The bytes of the text `s` in UTF-8, or a throw of type-error when `s`
isn't a string. A lone surrogate, which UTF-8 can't hold, becomes U+FFFD
on both platforms, as with TextEncoder.
sourceraw docstring

from-base64clj/s

(from-base64 s)

The bytes of the base64 text s, which has its padding, or nil when it isn't base64.

The bytes of the base64 text `s`, which has its padding, or nil when it
isn't base64.
sourceraw docstring

from-base64urlclj/s

(from-base64url s)

The bytes of the base64url text s, with or without padding, or nil when it isn't base64url.

The bytes of the base64url text `s`, with or without padding, or nil
when it isn't base64url.
sourceraw docstring

from-hexclj/s

(from-hex s)

The bytes of the hexadecimal text s, in upper or lower case, or nil when it isn't hexadecimal or has an odd number of digits.

The bytes of the hexadecimal text `s`, in upper or lower case, or nil
when it isn't hexadecimal or has an odd number of digits.
sourceraw docstring

hexclj/s

(hex b)

The bytes b in hexadecimal, two digits in lower case for each byte.

The bytes `b` in hexadecimal, two digits in lower case for each byte.
sourceraw docstring

lengthclj/s

(length b)

The number of bytes in b.

The number of bytes in `b`.
sourceraw docstring

ofclj/s

(of xs)

The bytes of the numbers xs, each from 0 to 255.

The bytes of the numbers `xs`, each from 0 to 255.
sourceraw docstring

same-text?clj/s

(same-text? a b)

Whether a and b are the same text, in a time that doesn't tell where they differ. Nil or another value is never the same.

Whether `a` and `b` are the same text, in a time that doesn't tell where
they differ. Nil or another value is never the same.
sourceraw docstring

same?clj/s

(same? a b)

Whether a and b are the same bytes, in a time that doesn't tell where they differ, as a comparison of secrets needs. Nil or another value is never the same.

Whether `a` and `b` are the same bytes, in a time that doesn't tell where
they differ, as a comparison of secrets needs. Nil or another value is
never the same.
sourceraw docstring

sliceclj/s

(slice b start)
(slice b start end)

The bytes of b from start to end, or to the end of b, as new bytes. It throws when they aren't within b.

The bytes of `b` from `start` to `end`, or to the end of `b`, as new
bytes. It throws when they aren't within `b`.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close