mirror of
https://github.com/pezkuwichain/pezkuwi-common.git
synced 2026-04-26 04:07:58 +00:00
chore: update to version 14.0.11 and align website URLs
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* @name blake2AsU8a
|
||||
* @summary Creates a blake2b u8a from the input.
|
||||
* @description
|
||||
* From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import { blake2AsU8a } from '@pezkuwi/util-crypto';
|
||||
*
|
||||
* blake2AsU8a('abc'); // => [0xba, 0x80, 0xa5, 0x3f, 0x98, 0x1c, 0x4d, 0x0d]
|
||||
* ```
|
||||
*/
|
||||
export declare function blake2AsU8a(data: string | Uint8Array, bitLength?: 64 | 128 | 256 | 384 | 512, key?: Uint8Array | null, onlyJs?: boolean): Uint8Array;
|
||||
/**
|
||||
* @name blake2AsHex
|
||||
* @description Creates a blake2b hex from the input.
|
||||
*/
|
||||
export declare const blake2AsHex: (data: string | Uint8Array, bitLength?: 256 | 512 | 64 | 128 | 384 | undefined, key?: Uint8Array | null | undefined, onlyJs?: boolean | undefined) => import("@pezkuwi/util/types").HexString;
|
||||
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.blake2AsHex = void 0;
|
||||
exports.blake2AsU8a = blake2AsU8a;
|
||||
const blake2b_1 = require("@noble/hashes/blake2b");
|
||||
const util_1 = require("@pezkuwi/util");
|
||||
const wasm_crypto_1 = require("@pezkuwi/wasm-crypto");
|
||||
const helpers_js_1 = require("../helpers.js");
|
||||
/**
|
||||
* @name blake2AsU8a
|
||||
* @summary Creates a blake2b u8a from the input.
|
||||
* @description
|
||||
* From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`.
|
||||
* @example
|
||||
* <BR>
|
||||
*
|
||||
* ```javascript
|
||||
* import { blake2AsU8a } from '@pezkuwi/util-crypto';
|
||||
*
|
||||
* blake2AsU8a('abc'); // => [0xba, 0x80, 0xa5, 0x3f, 0x98, 0x1c, 0x4d, 0x0d]
|
||||
* ```
|
||||
*/
|
||||
function blake2AsU8a(data, bitLength = 256, key, onlyJs) {
|
||||
const byteLength = Math.ceil(bitLength / 8);
|
||||
const u8a = (0, util_1.u8aToU8a)(data);
|
||||
return !util_1.hasBigInt || (!onlyJs && (0, wasm_crypto_1.isReady)())
|
||||
? (0, wasm_crypto_1.blake2b)(u8a, (0, util_1.u8aToU8a)(key), byteLength)
|
||||
: key
|
||||
? (0, blake2b_1.blake2b)(u8a, { dkLen: byteLength, key })
|
||||
: (0, blake2b_1.blake2b)(u8a, { dkLen: byteLength });
|
||||
}
|
||||
/**
|
||||
* @name blake2AsHex
|
||||
* @description Creates a blake2b hex from the input.
|
||||
*/
|
||||
exports.blake2AsHex = (0, helpers_js_1.createAsHex)(blake2AsU8a);
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* @summary Create blake2b values with specified bitlengths
|
||||
*/
|
||||
export { blake2AsHex, blake2AsU8a } from './asU8a.js';
|
||||
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.blake2AsU8a = exports.blake2AsHex = void 0;
|
||||
/**
|
||||
* @summary Create blake2b values with specified bitlengths
|
||||
*/
|
||||
var asU8a_js_1 = require("./asU8a.js");
|
||||
Object.defineProperty(exports, "blake2AsHex", { enumerable: true, get: function () { return asU8a_js_1.blake2AsHex; } });
|
||||
Object.defineProperty(exports, "blake2AsU8a", { enumerable: true, get: function () { return asU8a_js_1.blake2AsU8a; } });
|
||||
Reference in New Issue
Block a user