default

Overview

Functions

f
importPrivateKey(
privateKey: string | Uint8Array,
options?: ImportPrivateKeyOptions
): Promise<CryptoKey>
2 overloads

Imports an x25519 private key as a CryptoKey by wrapping it in PKCS8 format.

f
randomBytes(): Uint8Array

Generates UNCLAMPED 32 bytes of random data.

f
randomPresharedKeyBytes(): Uint8Array

Generates random preshared key bytes.

f
randomPrivateKeyBytes(): Uint8Array

Generates clamped private key from random data.

f
wgGenKey(): string

Mimics WireGuard's wg genkey command. Alias for randomPrivateKeyBytes, returns base64 encoded private key instead of Uint8Array. Can be used directly by WireGuard as Interface PrivateKey.

f
wgGenPsk(): string

Mimics WireGuard's wg genpsk command. Alias for randomPresharedKeyBytes, returns base64 encoded preshared key instead of Uint8Array. Can be used directly by WireGuard as Peer PresharedKey.

Type Aliases

T
ImportPrivateKeyOptions = { algorithm?: AlgorithmIdentifier; extractable?: boolean; keyUsages?: KeyUsage[]; }

Options for importing a private key into a CryptoKey.

T
ImportPublicKeyOptions = { algorithm?: AlgorithmIdentifier; extractable?: boolean; }

Options for importing a public key into a CryptoKey.