Advertisement
k98kurz

rxcipher.3.2.min.js

Dec 16th, 2014 (edited)
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function RXCipher(r,n){function t(r){var n,t=new Uint8Array(r.length);n=g.get(r.length);for(var e=0,i=r.length;i>e;++e)t[e]=r[e]^n[e];return t}function e(r){var n,t=new Uint8Array(r.length);n=g.get(r.length);for(var e=0,i=r.length;i>e;++e)t[e]=r[e]^n[e];return t}function i(r,n,t){return t[0]=r+n,t[0]^n}function o(r,n,t){return t[0]=(r^n)-n,t[0]}function a(r){function n(){var r=new Uint32Array(1);return r[0]=t[0]^t<<11,t[0]=e[0],e[0]=i[0],i[0]=o[0],o[0]=o[0]^o[0]>>19^(r[0]^r[0]>>8),o[0]+e[0]}var t=new Uint32Array(1),e=new Uint32Array(1),i=new Uint32Array(1),o=new Uint32Array(1);t[0]=r?0|r:317973455,e[0]=t[0]<<362436069,i[0]=e[0]+t[0],o[0]=i[0]^t[0]+e[0];for(var a=0,f=(n(),n()%256);f>=a;n(),++a);this.next=function(r,t){if("undefined"==typeof r||"number"!=typeof r)var r=1;var e;if(r|=0,r=r>0?r:1,"undefined"==typeof t||"number"!=typeof r)var t=0;switch(t){case 1:e=[];for(var i=0,o=r;o>i;e[i++]=n().toString(16));break;case 2:e=new Uint8Array(r);for(var i=0,o=r;o>i;e[i++]=n());break;case 3:e=[];for(var i=0,o=r;o>i;e[i]=(n()%256).toString(16),e[i]=e[i].length%2?"0"+e[i]:e[i],++i);break;case 4:e=[];for(var i=0,o=r;o>i;e[i]=(n()%256).toString(16),e[i]=e[i].length%2?"0"+e[i]:e[i],++i);e=e.join("");break;default:e=new Uint32Array(r);for(var i=0,o=r;o>i;e[i++]=n());}return e},this.nextHex=function(r){return this.next(r,1)},this.bytes=function(r){return this.next(r,2)},this.bytesHex=function(r){return this.next(r,3)},this.hex=function(r){return this.next(r,4)}}function f(r,n){function t(){return c=++c==y?0:c,h=64==++h?0:h,f[h]=i(f[h],r[c],g),f[63-h]=i(f[63-h],f[h],g),f[h]}var e,f,y,c,h,s,p,g=new Uint8Array(1);if("undefined"==typeof r)throw new Error("RXCipher@KeyStream: key required");if("object"==typeof r&&r instanceof Array&&(r="number"==typeof r[0]?new Uint8Array(r):r.join("")),"string"==typeof r&&(r=u(r)),"object"!=typeof r&&!(r instanceof Uint8Array))throw new Error("RXCipher@KeyStream: expected key of type String, Array, or Uint8Array");if("undefined"==typeof n&&(n="0123456"),"object"==typeof n&&n instanceof Array&&(n="number"==typeof n[0]?new Uint8Array(n):n.join("")),"string"==typeof n&&(n=u(n)),!(n instanceof Uint8Array)||0==n.length)throw new Error("RXCipher@KeyStream: expected iv of type String, Array or Uint8Array, or undefined");e=[],y=r.length,c=0,f=new Uint8Array(64),h=0;for(var v=0;y>v;v++)e[v]=new a(r[v]);for(var v=0,p=0,w=0;4*y>w;++v,++p,++w)p=p==y?0:p,v=v==n.length?0:v,r[p]=r[p]+n[v];for(var v=0,p=0;64>v;++v,++p)p=p==y?0:p,f[v]=e[p].next()[0];for(var s,A,v=63,p=0;v>=0;--v,++p)p=p==y?0:p,s=(e[p].next()[0]+r[p])%64,A=f[s],f[s]=i(f[v],r[p],g),f[v]=o(A,s,g);this.get=function(r){r=0|r?0|r:parseInt(r)?parseInt(r):1;for(var n=new Uint8Array(r),e=0;r>e;++e)n[e]=t();return n}}function u(r){for(var n,t=[],e=0;e<r.length;e++)n=r.charCodeAt(e),128>n?t.push(n):2048>n?t.push(192|n>>6,128|63&n):55296>n||n>=57344?t.push(224|n>>12,128|n>>6&63,128|63&n):(e++,n=65536+((1023&n)<<10|1023&r.charCodeAt(e)),t.push(240|n>>18,128|n>>12&63,128|n>>6&63,128|63&n));return new Uint8Array(t)}function y(r){for(var n="",t="",e=0,i=r.length;i>e;e++)r[e]<=127?(n+=c(t)+String.fromCharCode(r[e]),t=""):t+="%"+r[e].toString(16);return n+c(t)}function c(r){try{return decodeURIComponent(r)}catch(n){return String.fromCharCode(65533)}}function h(r){for(var n=[],t=0,e=r.length;e>t;++t)n[t]=r[t].toString(16),n[t]=n[t].length%2?"0"+n[t]:n[t];return n.join("")}function s(r){for(var n=new Uint8Array(r.length/2),t=0,e=0,i=r.length;i>t;++t,++e)n[e]=parseInt(r[t]+r[++t],16);return n}var p,g,v=n;p="object"==typeof r&&r instanceof Uint8Array?y(r):r,v="object"==typeof n&&n instanceof Uint8Array?y(n):n,g=new f(p,v),this.encrypt=function(r){var n=t(u(r));return h(n)},this.decrypt=function(r){var n=e(s(r));return y(n)},this.encryptRaw=function(r){return t(u(r))},this.decryptRaw=function(r){return y(e(r))},this.getKeyStream=function(){return new f(p,v)},this.reset=function(){return g=new f(p,v),this}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement