summaryrefslogtreecommitdiffhomepage
path: root/packages/server/src/helpers/iso/isoCrypto/getRandomValues.ts
blob: 04f32212318fb5094b88e261518a6a8cd48ba44e (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;
}