Blame view

utils/string-code.js 329 Bytes
OF1706 authored
1 2
'use strict';
OF1706 authored
3 4
const _ = require('lodash');
OF1706 authored
5 6 7
const utf8ToHex = (string) => {
    var buf = new Buffer(string, 'utf8');
OF1706 authored
8
    return _.toUpper(buf.toString('hex'));
OF1706 authored
9 10 11 12 13 14 15 16 17 18 19 20
};

const hexToUtf8 = (string) => {
    let buf = new Buffer(string, 'hex');

    return buf.toString('utf8');
};

module.exports = {
    utf8ToHex,
    hexToUtf8
};