function randomBytes
randomBytes(): Uint8Array

Generates UNCLAMPED 32 bytes of random data.

Useful for generating preshared keys, but NOT private keys.

Examples

Generate 32 random bytes

import { assertEquals, assertNotEquals } from "@std/assert";
import { randomBytes } from "@hertzg/wg-keys";

const a = randomBytes();
const b = randomBytes();

assertEquals(a.length, 32);
assertEquals(b.length, 32);
assertNotEquals(a, b);

Return Type

32 bytes of random data

See

Usage

import { randomBytes } from ".";