Blame view

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

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

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

module.exports = {
    utf8ToHex,
郝肖肖 authored
19
    hexToUtf8
yyq authored
20
};