Files
common/packages/x-randomvalues/src/node.ts
T
2022-01-01 09:26:11 +02:00

17 lines
404 B
TypeScript

// Copyright 2017-2022 @polkadot/x-randomvalues authors & contributors
// SPDX-License-Identifier: Apache-2.0
import crypto from 'crypto';
export { packageInfo } from './packageInfo';
export function getRandomValues <T extends Uint8Array> (output: T): T {
const bytes = crypto.randomBytes(output.length);
for (let i = 0; i < bytes.length; i++) {
output[i] = bytes[i];
}
return output;
}