1/* 2https://jsfiddle.net/veeresh/k0e5dtjL/ 3 */ 4(function(exports) { 5 "use strict"; 6 7 var XORCipher = { 8 encode: function(key, data) { 9 data = xor_encrypt(key, data); 10 return b64_encode(data); 11 }, 12 decode: function(key, data) { 13 data = b64_decode(data); 14 return xor_decrypt(key, data); 15 } 16 }; 17 18 var b64_table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 19 20 function b64_encode(data) { 21 var o1, o2, o3, h1, h2, h3, h4, bits, r, i = 0, enc = ""; 22 if (!data) { return data; } 23 do { 24 o1 = data[i++]; 25 o2 = data[i++]; 26 o3 = data[i++]; 27 bits = o1 << 16 | o2 << 8 | o3; 28 h1 = bits >> 18 & 0x3f; 29 h2 = bits >> 12 & 0x3f; 30 h3 = bits >> 6 & 0x3f; 31 h4 = bits & 0x3f; 32 enc += b64_table.charAt(h1) + b64_table.charAt(h2) + b64_table.charAt(h3) + b64_table.charAt(h4); 33 } while (i < data.length); 34 r = data.length % 3; 35 return (r ? enc.slice(0, r - 3) : enc) + "===".slice(r || 3); 36 } 37 38 function b64_decode(data) { 39 var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, result = []; 40 if (!data) { return data; } 41 data += ""; 42 do { 43 h1 = b64_table.indexOf(data.charAt(i++)); 44 h2 = b64_table.indexOf(data.charAt(i++)); 45 h3 = b64_table.indexOf(data.charAt(i++)); 46 h4 = b64_table.indexOf(data.charAt(i++)); 47 bits = h1 << 18 | h2 << 12 | h3 << 6 | h4; 48 o1 = bits >> 16 & 0xff; 49 o2 = bits >> 8 & 0xff; 50 o3 = bits & 0xff; 51 result.push(o1); 52 if (h3 !== 64) { 53 result.push(o2); 54 if (h4 !== 64) { 55 result.push(o3); 56 } 57 } 58 } while (i < data.length); 59 return result; 60 } 61 62 function keyCharAt(key, i) { 63 return key.charCodeAt( Math.floor(i % key.length) ); 64 } 65 66 function xor_encrypt(key, data) { 67 return data.split('').map(function(c, i) { 68 return c.charCodeAt(0) ^ keyCharAt(key, i); 69 }); 70 } 71 72 function xor_decrypt(key, data) { 73 return data.map(function(c, i) { 74 return String.fromCharCode( c ^ keyCharAt(key, i) ); 75 }).join(""); 76 } 77 78 exports.XORCipher = XORCipher; 79 80})(this);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.