12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- ;(function () {
- var object = typeof exports != 'undefined' ? exports : this;
- var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
- function InvalidCharacterError(message) {
- this.message = message;
- }
- InvalidCharacterError.prototype = new Error;
- InvalidCharacterError.prototype.name = 'InvalidCharacterError';
-
-
- object.btoa || (
- object.btoa = function (input) {
- for (
-
- var block, charCode, idx = 0, map = chars, output = '';
-
-
-
- input.charAt(idx | 0) || (map = '=', idx % 1);
-
- output += map.charAt(63 & block >> 8 - idx % 1 * 8)
- ) {
- charCode = input.charCodeAt(idx += 3/4);
- if (charCode > 0xFF) {
- throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
- }
- block = block << 8 | charCode;
- }
- return output;
- });
-
-
- object.atob || (
- object.atob = function (input) {
- input = input.replace(/=+$/, '')
- if (input.length % 4 == 1) {
- throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
- }
- for (
-
- var bc = 0, bs, buffer, idx = 0, output = '';
-
- buffer = input.charAt(idx++);
-
- ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
-
-
- bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
- ) {
-
- buffer = chars.indexOf(buffer);
- }
- return output;
- });
- }());
|