Documentation Index
Fetch the complete documentation index at: https://mintlify.com/tkhq/sdk/llms.txt
Use this file to discover all available pages before exploring further.
@turnkey/encoding provides pure-JS encoding and decoding utilities used internally throughout the Turnkey SDK. It handles base64url, hex, and Base58 conversions without runtime dependencies on Node.js built-ins or browser globals.
This is primarily an internal package. Its functions are consumed by
@turnkey/http, @turnkey/crypto, @turnkey/api-key-stamper, and other SDK packages. You are welcome to use these utilities in your own code, but be aware that interfaces may change between major versions.Installation
Hex utilities
uint8ArrayToHexString
Converts aUint8Array into a lowercase hex string.
The byte array to convert.
uint8ArrayFromHexString
Creates aUint8Array from a hex string. Optionally pads the result to a target byte length.
A valid even-length hex string (only
[0-9A-Fa-f] characters).Optional target length in bytes. The result will be left-padded with zero bytes if needed. Throws if the hex value cannot fit.
hexToAscii
Converts a hex string to an ASCII string by interpreting each byte pair as a character code.normalizePadding
Pads or trims aUint8Array to a target byte length by adding or removing leading zero bytes.
The input byte array.
The desired output length in bytes.
Base64url utilities
stringToBase64urlString
Encodes a plain string to a base64url string. Uses a pure-JSbtoa implementation that works in React Native and other environments without a native btoa.
hexStringToBase64url
Converts a hex string to a base64url string.base64StringToBase64UrlEncodedString
Converts a standard base64 string to base64url format by replacing+ with -, / with _, and stripping = padding.
base64UrlToBase64
Converts a base64url string back to a standard base64 string (restores+, /, and = padding).
decodeBase64urlToString
Decodes a base64url string to a plain UTF-8 string.atob
A pure-JS implementation of the standardatob function. Exported for environments that may not have it available globally.
Point encoding
pointEncode
Compresses an uncompressed P-256 public key (65 bytes,0x04 prefix) into its 33-byte compressed form.
A 65-byte uncompressed public key starting with
0x04.Base58 utilities
@turnkey/encoding exports bs58 and bs58check for Base58 and Base58Check encoding, used primarily for Solana key formats and credential bundles.