UNPKG

mysql-restful

Version:
70 lines (69 loc) 3.14 kB
/* * Crypto-JS v2.5.3 * http://code.google.com/p/crypto-js/ * (c) 2009-2012 by Jeff Mott. All rights reserved. * http://code.google.com/p/crypto-js/wiki/License */ (typeof Crypto == "undefined" || !Crypto.util) && function() { var e = window.Crypto = {}, g = e.util = { rotl: function(a, b) { return a << b | a >>> 32 - b; }, rotr: function(a, b) { return a << 32 - b | a >>> b; }, endian: function(a) { if (a.constructor == Number) return g.rotl(a, 8) & 16711935 | g.rotl(a, 24) & 4278255360; for (var b = 0; b < a.length; b++) a[b] = g.endian(a[b]); return a; }, randomBytes: function(a) { for (var b = []; a > 0; a--) b.push(Math.floor(Math.random() * 256)); return b; }, bytesToWords: function(a) { for (var b = [], c = 0, d = 0; c < a.length; c++, d += 8) b[d >>> 5] |= (a[c] & 255) << 24 - d % 32; return b; }, wordsToBytes: function(a) { for (var b = [], c = 0; c < a.length * 32; c += 8) b.push(a[c >>> 5] >>> 24 - c % 32 & 255); return b; }, bytesToHex: function(a) { for (var b = [], c = 0; c < a.length; c++) b.push((a[c] >>> 4).toString(16)), b.push((a[c] & 15).toString(16)); return b.join(""); }, hexToBytes: function(a) { for (var b = [], c = 0; c < a.length; c += 2) b.push(parseInt(a.substr(c, 2), 16)); return b; }, bytesToBase64: function(a) { if (typeof btoa == "function") return btoa(f.bytesToString(a)); for (var b = [], c = 0; c < a.length; c += 3) for (var d = a[c] << 16 | a[c + 1] << 8 | a[c + 2], e = 0; e < 4; e++) c * 8 + e * 6 <= a.length * 8 ? b.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(d >>> 6 * (3 - e) & 63)) : b.push("="); return b.join(""); }, base64ToBytes: function(a) { if (typeof atob == "function") return f.stringToBytes(atob(a)); for (var a = a.replace(/[^A-Z0-9+\/]/ig, ""), b = [], c = 0, d = 0; c < a.length; d = ++c % 4) d != 0 && b.push(("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c - 1)) & Math.pow(2, - 2 * d + 8) - 1) << d * 2 | "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a.charAt(c)) >>> 6 - d * 2); return b; } }, e = e.charenc = {}; e.UTF8 = { stringToBytes: function(a) { return f.stringToBytes(unescape(encodeURIComponent(a))); }, bytesToString: function(a) { return decodeURIComponent(escape(f.bytesToString(a))); } }; var f = e.Binary = { stringToBytes: function(a) { for (var b = [], c = 0; c < a.length; c++) b.push(a.charCodeAt(c) & 255); return b; }, bytesToString: function(a) { for (var b = [], c = 0; c < a.length; c++) b.push(String.fromCharCode(a[c])); return b.join(""); } } }();