Server IP : 66.29.132.122 / Your IP : 3.147.78.117 Web Server : LiteSpeed System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : admazpex ( 531) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/opt/cpanel/ea-ruby27/root/usr/share/passenger/node/vendor-copy/codify/ |
Upload File : |
var codify = module.exports = {}; // This function accepts numbers from 0-35 function character(num) { if (num < 10) return String(num); return String.fromCharCode(num-10+65); } /* * Generate an alphanumeric (base-36) code from an integer */ codify.toCode = function(val, minSize) { minSize = minSize || 1; var code = ''; while (val >= 1) { var remainder = val % 36; val = Math.floor(val / 36); code = character(remainder)+code; } while (code.length < minSize) { code = '0'+code; } return code; }; var digits = {}; for (var i = 0; i < 10; i++) { digits[String(i)] = i; } for (i = 0; i < 26; i++) { digits[String.fromCharCode(i+65)] = i+10; } /* * Convert an alphanumeric (base-36) code to an integer */ codify.toInt = function(code) { var calculated = 0; for (var i =0; i < code.length; i++) { var num = digits[code.charAt(i)]; calculated += Math.pow(36, code.length-i-1)*num; } return calculated; };