mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-22 07:57:59 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* @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 declare function randomAsNumber(): number;
|
||||
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.randomAsNumber = randomAsNumber;
|
||||
const util_1 = require("@pezkuwi/util");
|
||||
const asU8a_js_1 = require("./asU8a.js");
|
||||
const BN_53 = new util_1.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>
|
||||
* ```
|
||||
*/
|
||||
function randomAsNumber() {
|
||||
return (0, util_1.hexToBn)((0, asU8a_js_1.randomAsHex)(8)).and(BN_53).toNumber();
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @name randomAsU8a
|
||||
* @summary Creates a Uint8Array filled with random bytes.
|
||||
* @description
|
||||
* Returns a `Uint8Array` with the specified (optional) length filled with random bytes.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import { randomAsU8a } from '@pezkuwi/util-crypto';
|
||||
*
|
||||
* randomAsU8a(); // => Uint8Array([...])
|
||||
* ```
|
||||
*/
|
||||
export declare function randomAsU8a(length?: number): Uint8Array;
|
||||
/**
|
||||
* @name randomAsHex
|
||||
* @description Creates a hex string filled with random bytes.
|
||||
*/
|
||||
export declare const randomAsHex: (length?: number | undefined) => import("@pezkuwi/util/types").HexString;
|
||||
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.randomAsHex = void 0;
|
||||
exports.randomAsU8a = randomAsU8a;
|
||||
const x_randomvalues_1 = require("@pezkuwi/x-randomvalues");
|
||||
const helpers_js_1 = require("../helpers.js");
|
||||
/**
|
||||
* @name randomAsU8a
|
||||
* @summary Creates a Uint8Array filled with random bytes.
|
||||
* @description
|
||||
* Returns a `Uint8Array` with the specified (optional) length filled with random bytes.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import { randomAsU8a } from '@pezkuwi/util-crypto';
|
||||
*
|
||||
* randomAsU8a(); // => Uint8Array([...])
|
||||
* ```
|
||||
*/
|
||||
function randomAsU8a(length = 32) {
|
||||
return (0, x_randomvalues_1.getRandomValues)(new Uint8Array(length));
|
||||
}
|
||||
/**
|
||||
* @name randomAsHex
|
||||
* @description Creates a hex string filled with random bytes.
|
||||
*/
|
||||
exports.randomAsHex = (0, helpers_js_1.createAsHex)(randomAsU8a);
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* @summary Returns a sequence of secure random bytes in a variety of formats
|
||||
*/
|
||||
export { randomAsNumber } from './asNumber.js';
|
||||
export { randomAsHex, randomAsU8a } from './asU8a.js';
|
||||
@@ -0,0 +1,11 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.randomAsU8a = exports.randomAsHex = exports.randomAsNumber = void 0;
|
||||
/**
|
||||
* @summary Returns a sequence of secure random bytes in a variety of formats
|
||||
*/
|
||||
var asNumber_js_1 = require("./asNumber.js");
|
||||
Object.defineProperty(exports, "randomAsNumber", { enumerable: true, get: function () { return asNumber_js_1.randomAsNumber; } });
|
||||
var asU8a_js_1 = require("./asU8a.js");
|
||||
Object.defineProperty(exports, "randomAsHex", { enumerable: true, get: function () { return asU8a_js_1.randomAsHex; } });
|
||||
Object.defineProperty(exports, "randomAsU8a", { enumerable: true, get: function () { return asU8a_js_1.randomAsU8a; } });
|
||||
Reference in New Issue
Block a user