From 824a2d9f587ca017fc71b84d835e72f54f9c87c4 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 7 Nov 2018 18:02:36 +0100 Subject: Began rewrite --- node_modules/locutus/php/strings/bin2hex.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 node_modules/locutus/php/strings/bin2hex.js (limited to 'node_modules/locutus/php/strings/bin2hex.js') diff --git a/node_modules/locutus/php/strings/bin2hex.js b/node_modules/locutus/php/strings/bin2hex.js new file mode 100644 index 0000000..344c03d --- /dev/null +++ b/node_modules/locutus/php/strings/bin2hex.js @@ -0,0 +1,28 @@ +'use strict'; + +module.exports = function bin2hex(s) { + // discuss at: http://locutus.io/php/bin2hex/ + // original by: Kevin van Zonneveld (http://kvz.io) + // bugfixed by: Onno Marsman (https://twitter.com/onnomarsman) + // bugfixed by: Linuxworld + // improved by: ntoniazzi (http://locutus.io/php/bin2hex:361#comment_177616) + // example 1: bin2hex('Kev') + // returns 1: '4b6576' + // example 2: bin2hex(String.fromCharCode(0x00)) + // returns 2: '00' + + var i; + var l; + var o = ''; + var n; + + s += ''; + + for (i = 0, l = s.length; i < l; i++) { + n = s.charCodeAt(i).toString(16); + o += n.length < 2 ? '0' + n : n; + } + + return o; +}; +//# sourceMappingURL=bin2hex.js.map \ No newline at end of file -- cgit v1.2.3