summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/iso/isoCrypto/getRandomValues.ts
blob: 5f5e5949de77a0ae9711176c8926176fa0c01c9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { getWebCrypto } from "./getWebCrypto.ts";

/**
 * Fill up the provided bytes array with random bytes equal to its length.
 *
 * @returns the same bytes array passed into the method
 */
export async function getRandomValues(array: Uint8Array): Promise<Uint8Array> {
  const WebCrypto = await getWebCrypto();

  WebCrypto.getRandomValues(array);

  return array;
}