Skip to main content
@tevm/voltaire
@tevm/voltaire / index / BrandedBase64

BrandedBase64

Functions

calcDecodedSize()

calcDecodedSize(encodedLength): number
Defined in: src/primitives/Base64/calcDecodedSize.js:7 Calculate decoded size in bytes

Parameters

encodedLength
number Length of base64 string

Returns

number Maximum size of decoded output

calcEncodedSize()

calcEncodedSize(dataLength): number
Defined in: src/primitives/Base64/calcEncodedSize.js:7 Calculate encoded size in bytes

Parameters

dataLength
number Length of data to encode

Returns

number Size of base64 output

decode()

decode(encoded): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Base64/decode.js:19 Decode standard base64 string to bytes

Parameters

encoded
string Base64 string to decode

Returns

Uint8Array<ArrayBufferLike> Decoded bytes

See

https://voltaire.tevm.sh/primitives/base64 for Base64 documentation

Since

0.0.0

Throws

If input is invalid base64

Example


decodeToString()

decodeToString(encoded): string
Defined in: src/primitives/Base64/decodeToString.js:15 Decode base64 string to UTF-8 string

Parameters

encoded
string Base64 string

Returns

string Decoded string

Example


decodeUrlSafe()

decodeUrlSafe(encoded): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Base64/decodeUrlSafe.js:10 Decode URL-safe base64 string to bytes

Parameters

encoded
string URL-safe base64 string

Returns

Uint8Array<ArrayBufferLike> Decoded bytes

Throws

If input is invalid

decodeUrlSafeToString()

decodeUrlSafeToString(encoded): string
Defined in: src/primitives/Base64/decodeUrlSafeToString.js:9 Decode URL-safe base64 to UTF-8 string

Parameters

encoded
string URL-safe base64 string

Returns

string Decoded string

encode()

encode(data): BrandedBase64
Defined in: src/primitives/Base64/encode.js:19 Encode bytes to standard base64 string Uses standard base64 alphabet (A-Z, a-z, 0-9, +, /) with padding (=)

Parameters

data
Uint8Array<ArrayBufferLike> Bytes to encode

Returns

BrandedBase64 Base64-encoded string

Example


encodeString()

encodeString(str): string
Defined in: src/primitives/Base64/encodeString.js:14 Encode string to base64

Parameters

str
string String to encode (UTF-8)

Returns

string Base64-encoded string

Example


encodeStringUrlSafe()

encodeStringUrlSafe(str): BrandedBase64Url
Defined in: src/primitives/Base64/encodeStringUrlSafe.js:9 Encode string to URL-safe base64

Parameters

str
string String to encode (UTF-8)

Returns

BrandedBase64Url URL-safe base64 string

encodeUrlSafe()

encodeUrlSafe(data): BrandedBase64Url
Defined in: src/primitives/Base64/encodeUrlSafe.js:19 Encode bytes to URL-safe base64 string Uses URL-safe alphabet (A-Z, a-z, 0-9, -, _) without padding

Parameters

data
Uint8Array<ArrayBufferLike> Bytes to encode

Returns

BrandedBase64Url URL-safe base64 string

Example


from()

from(value): BrandedBase64
Defined in: src/primitives/Base64/from.js:21 Convert input to BrandedBase64

Parameters

value
Base64Like Input to convert

Returns

BrandedBase64 Branded Base64 string

Throws

If input cannot be converted to valid Base64

Example


fromUrlSafe()

fromUrlSafe(value): BrandedBase64Url
Defined in: src/primitives/Base64/fromUrlSafe.js:21 Convert input to BrandedBase64Url

Parameters

value
Base64UrlLike Input to convert

Returns

BrandedBase64Url Branded Base64Url string

Throws

If input cannot be converted to valid Base64Url

Example


isValid()

isValid(str): boolean
Defined in: src/primitives/Base64/isValid.js:7 Check if string is valid base64

Parameters

str
string String to validate

Returns

boolean True if valid base64

isValidUrlSafe()

isValidUrlSafe(str): boolean
Defined in: src/primitives/Base64/isValidUrlSafe.js:7 Check if string is valid URL-safe base64

Parameters

str
string String to validate

Returns

boolean True if valid URL-safe base64

toBase64()

toBase64(value): BrandedBase64
Defined in: src/primitives/Base64/toBase64.js:17 Convert BrandedBase64Url to BrandedBase64

Parameters

value
BrandedBase64Url Base64Url string

Returns

BrandedBase64 Base64 string

Example


toBase64Url()

toBase64Url(value): BrandedBase64Url
Defined in: src/primitives/Base64/toBase64Url.js:17 Convert BrandedBase64 to BrandedBase64Url

Parameters

value
BrandedBase64 Base64 string

Returns

BrandedBase64Url Base64Url string

Example


toBytes()

toBytes(value): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Base64/toBytes.js:16 Convert BrandedBase64 to bytes

Parameters

value
BrandedBase64 Base64 string

Returns

Uint8Array<ArrayBufferLike> Decoded bytes

Example


toBytesUrlSafe()

toBytesUrlSafe(value): Uint8Array<ArrayBufferLike>
Defined in: src/primitives/Base64/toBytesUrlSafe.js:16 Convert BrandedBase64Url to bytes

Parameters

value
BrandedBase64Url Base64Url string

Returns

Uint8Array<ArrayBufferLike> Decoded bytes

Example


toString()

toString(value): string
Defined in: src/primitives/Base64/toString.js:15 Convert BrandedBase64 to plain string (strip branding)

Parameters

value
BrandedBase64 Base64 string

Returns

string Plain string

Example


toStringUrlSafe()

toStringUrlSafe(value): string
Defined in: src/primitives/Base64/toStringUrlSafe.js:14 Convert BrandedBase64Url to plain string (strip branding)

Parameters

value
BrandedBase64Url Base64Url string

Returns

string Plain string

Example

References

Base64

Re-exports Base64