UNPKG

slashjs

Version:
7 lines 2.51 kB
/** * Slash v1.0.0 * Copyright 2017 Kabir Shah * Released under the MIT License * https://github.com/kbrsh/slashjs */ !function(t,o){"object"==typeof module&&module.exports?module.exports=o():t.Slash=o()}(this,function(){function t(t,o){return this.high=t,this.low=o,this.__long__=!0,this}var o={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,10:10,11:11,12:12,13:13,14:14,15:15,16:16,17:17,18:18,19:19,20:20,21:21,22:22,23:23,24:24,25:25,26:26,27:27,28:28,29:29,30:30,31:31,32:32,33:33,34:34,35:35},i={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,10:"A",11:"B",12:"C",13:"D",14:"E",15:"F",16:"G",17:"H",18:"I",19:"J",20:"K",21:"L",22:"M",23:"N",24:"O",25:"P",26:"Q",27:"R",28:"S",29:"T",30:"U",31:"V",32:"W",33:"X",34:"Y",35:"Z"},r=function(t){var o=t.length;if(32===t.length)return t;for(var i=32-o,r="",h=0;h<i;h++)r+="0";return r+=t},h=function(t,o){for(var i=0;i<o;i++)t+="0";return t},e=function(t){for(var i=0,r=0;r<t.length;r++)i=(2*i+o[t[r]])%4294967295;return i};t.prototype.or=function(o){return void 0===o.__long__&&(o=new t(0,o)),new t((this.high|o.high)>>>0,(this.low|o.low)>>>0)},t.prototype.xor=function(o){return void 0===o.__long__&&(o=new t(0,o)),new t((this.high^o.high)>>>0,(this.low^o.low)>>>0)},t.prototype.shiftLeft=function(o){if(o<32){var i=this.high<<o>>>0,r=this.low<<o>>>0;return i<0&&(i=e(h(this.high.toString(2),o))),r<0&&(r=e(h(this.low.toString(2),o))),new t(i|this.low>>>32-o,r)}var n=o-32,f=this.low<<n>>>0;return f<0&&(f=e(h(this.low.toString(2),n))),new t(f,0)},t.prototype.shiftRight=function(o){return new t(this.high>>>o,this.low>>>o|this.high<<32-o)},t.prototype.rotateRight=function(t){return this.shiftRight(t).or(this.shiftLeft(64-t))},t.prototype.toString=function(t){void 0===t&&(t=10);for(var h=r(this.high.toString(2))+r(this.low.toString(2)),e="",n=0,f=[],s=0,g=0,u=0;0!==h.length;){for(u=0,f=[],n=0;n<h.length;n++)g=(s=o[h[n]]+2*u)/t|0,u=s%t,0===f.length&&0===g||f.push(g);h=f,e=i[u]+e}return e};return function(o,i){void 0===i&&(i=36);var r=new t(0,1),h=0,e=[];if("string"==typeof o)for(;h<o.length;h++)e[h]=o.charCodeAt(h);else e=o;for(h=0;h<e.length;h++)r=r.xor(r.shiftLeft(9).xor(r.shiftLeft(16).xor(r.shiftLeft(17).xor(r.shiftLeft(20).xor(r.shiftLeft(24).xor(r.shiftLeft(26).xor(r.shiftLeft(28).xor(r.shiftLeft(32).xor(r.shiftLeft(33).xor(r.shiftLeft(41).xor(r.shiftLeft(48).xor(r.shiftLeft(52).xor(r.shiftLeft(53).xor(r.shiftLeft(54).xor(r.shiftLeft(56).xor(r.shiftLeft(61).xor(r.shiftLeft(63)))))))))))))))))).xor(e[h]).rotateRight(7);return r.toString(i)}});