mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 09:08:03 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { BN, hexToBn } from '@pezkuwi/util';
|
||||
import { randomAsHex } from './asU8a.js';
|
||||
const BN_53 = new BN(0b11111111111111111111111111111111111111111111111111111);
|
||||
/**
|
||||
* @name randomAsNumber
|
||||
* @summary Creates a random number from random bytes.
|
||||
* @description
|
||||
* Returns a random number generated from the secure bytes.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import { randomAsNumber } from '@pezkuwi/util-crypto';
|
||||
*
|
||||
* randomAsNumber(); // => <random number>
|
||||
* ```
|
||||
*/
|
||||
export function randomAsNumber() {
|
||||
return hexToBn(randomAsHex(8)).and(BN_53).toNumber();
|
||||
}
|
||||
Reference in New Issue
Block a user