âš™ rotr32
Rotate right (32-bit unsigned)
| Function | Type |
|---|
rotr32 | (x: number, n: number) => number |
âš™ rotl32
Rotate left (32-bit unsigned)
| Function | Type |
|---|
rotl32 | (x: number, n: number) => number |
âš™ stringToBytes
Converts a UTF-8 string into an array of byte values (0-255)
| Function | Type |
|---|
stringToBytes | (str: string) => number[] |
âš™ bytesToString
Converts an array of byte values (0-255) into a UTF-8 string
| Function | Type |
|---|
bytesToString | (bytes: number[]) => string |
âš™ bytesToHex
Converts byte array to Hex string
| Function | Type |
|---|
bytesToHex | (bytes: number[]) => string |
âš™ hexToBytes
Converts Hex string to byte array
| Function | Type |
|---|
hexToBytes | (hex: string) => number[] |
âš™ constantTimeCompare
Compares two strings in constant time to prevent timing attacks
| Function | Type |
|---|
constantTimeCompare | (a: string, b: string) => boolean |
âš™ generateRandomHex
Generates pseudo-random hex string of specified byte length
| Function | Type |
|---|
generateRandomHex | (byteCount: number) => string |
âš™ generateKey
Generates a 128-bit (16-byte) random hex key suitable for SPECK-64/128
| Function | Type |
|---|
generateKey | () => string |
âš™ generateIV
Generates a 64-bit (8-byte) random hex IV suitable for SPECK-64/128 CTR
| Function | Type |
|---|
generateIV | () => string |
âš™ generateSalt
Generates a 128-bit (16-byte) random hex salt
| Function | Type |
|---|
generateSalt | () => string |
âš™ speckExpandKey
SPECK-64/128 key expansion algorithm.
Takes 128-bit key (4 x 32-bit words) and yields 27 round keys.
| Function | Type |
|---|
speckExpandKey | (k: number[]) => number[] |
âš™ speckEncryptBlock
Encrypts a single 64-bit block (two 32-bit words x, y) using SPECK-64/128
| Function | Type |
|---|
speckEncryptBlock | (x: number, y: number, rk: number[]) => [number, number] |
âš™ speckCTR
SPECK-64/128 Counter (CTR) Mode Cipher.
Encrypts/Decrypts arbitrary data using 128-bit key and 64-bit IV.
| Function | Type |
|---|
speckCTR | (dataBytes: number[], keyHex: string, ivHex: string) => number[] |
âš™ blake2s
Computes BLAKE2s-256 hash or keyed MAC over arbitrary input
| Function | Type |
|---|
blake2s | (inputStrOrBytes: string or number[], keyHex?: string or undefined) => string |
âš™ deriveKey
Derives a 128-bit Key Encryption Key (KEK) from a passphrase and salt.
Performs iterated BLAKE2s passes to slow down offline password cracking attempts.
| Function | Type |
|---|
deriveKey | (passphrase: string, saltHex: string, rounds?: number) => string |
âš™ encryptText
Encrypts a text string with SPECK-64/128 CTR and returns a Hex string
| Function | Type |
|---|
encryptText | (plaintext: string, keyHex: string, ivHex: string) => string |
âš™ decryptText
Decrypts a Hex ciphertext string with SPECK-64/128 CTR and returns text
| Function | Type |
|---|
decryptText | (ciphertextHex: string, keyHex: string, ivHex: string) => string |
🔧 Constants
âš™ SPECK_KEY_BYTES
Standard key, IV, salt, and digest byte lengths
| Constant | Type |
|---|
SPECK_KEY_BYTES | 16 |
âš™ SPECK_IV_BYTES
| Constant | Type |
|---|
SPECK_IV_BYTES | 8 |
âš™ SALT_BYTES
âš™ BLAKE2S_DIGEST_BYTES
| Constant | Type |
|---|
BLAKE2S_DIGEST_BYTES | 32 |
âš™ DEFAULT_KEY_DERIVATION_ROUNDS
| Constant | Type |
|---|
DEFAULT_KEY_DERIVATION_ROUNDS | 500 |