• This project
    • Loading...
  • Sign in

fe / yohobuy-node · Files

Go to a project

GitLab

  • Go to group
  • Project
  • Activity
  • Files
  • Commits
  • Pipelines 0
  • Builds 0
  • Graphs
  • Milestones
  • Issues 1
  • Merge Requests 0
  • Members
  • Labels
  • Wiki
  • Forks
  • Network
  • Create a new issue
  • yohobuy-node
  • utils
  • string-code.js
  • suggetList
    db466aa8
    by OF1706
    2017-06-12 11:25:00 +0800  
    Browse Files
string-code.js 329 Bytes
Raw Blame History Permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
'use strict';

const _ = require('lodash');

const utf8ToHex = (string) => {
    var buf = new Buffer(string, 'utf8');

    return _.toUpper(buf.toString('hex'));
};

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

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

module.exports = {
    utf8ToHex,
    hexToUtf8
};