UNPKG

464 BJavaScriptView Raw
1import { u8aToHex } from '../u8a/toHex.js';
2import { stringToU8a } from './toU8a.js';
3/**
4 * @name stringToHex
5 * @summary Creates a hex string from a utf-8 string
6 * @description
7 * String input values return the actual encoded hex value.
8 * @example
9 * <BR>
10 *
11 * ```javascript
12 * import { stringToHex } from '@polkadot/util';
13 *
14 * stringToU8a('hello'); // 0x68656c6c6f
15 * ```
16 */
17export function stringToHex(value) {
18 return u8aToHex(stringToU8a(value));
19}