@plugnet/util-crypto
Version:
A collection of useful crypto utilities for @plugnet
35 lines (29 loc) • 1.05 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = blake2AsHex;
var _util = require("@plugnet/util");
var _asU8a = _interopRequireDefault(require("./asU8a"));
// Copyright 2017-2019 @polkadot/util-crypto authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
/**
* @name blake2AsHex
* @summary Creates a blake2b hex from the input.
* @description
* From a `Uint8Array` input, create the blake2b and return the result as a hex string with the specified `bitLength`.
* @example
* <BR>
*
* ```javascript
* import { blake2AsHex } from '@plugnet/util-crypto';
*
* blake2AsHex('abc'); // => 0xba80a53f981c4d0d
* ```
*/
function blake2AsHex(data) {
let bitLength = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 256;
return (0, _util.u8aToHex)((0, _asU8a.default)(data, bitLength));
}