All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.bower_components.jszip.lib.base64.min.js Maven / Gradle / Ivy

The newest version!
"use strict";var utils=require("./utils");var support=require("./support");var _keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";exports.encode=function(input){var output=[];var chr1,chr2,chr3,enc1,enc2,enc3,enc4;var i=0,len=input.length,remainingBytes=len;var isArray=utils.getTypeOf(input)!=="string";while(i>2;enc2=(chr1&3)<<4|chr2>>4;enc3=remainingBytes>1?(chr2&15)<<2|chr3>>6:64;enc4=remainingBytes>2?chr3&63:64;output.push(_keyStr.charAt(enc1)+_keyStr.charAt(enc2)+_keyStr.charAt(enc3)+_keyStr.charAt(enc4))}return output.join("")};exports.decode=function(input){var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0,resultIndex=0;var dataUrlPrefix="data:";if(input.substr(0,dataUrlPrefix.length)===dataUrlPrefix){throw new Error("Invalid base64 input, it looks like a data url.")}input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");var totalLength=input.length*3/4;if(input.charAt(input.length-1)===_keyStr.charAt(64)){totalLength--}if(input.charAt(input.length-2)===_keyStr.charAt(64)){totalLength--}if(totalLength%1!==0){throw new Error("Invalid base64 input, bad content length.")}var output;if(support.uint8array){output=new Uint8Array(totalLength|0)}else{output=new Array(totalLength|0)}while(i>4;chr2=(enc2&15)<<4|enc3>>2;chr3=(enc3&3)<<6|enc4;output[resultIndex++]=chr1;if(enc3!==64){output[resultIndex++]=chr2}if(enc4!==64){output[resultIndex++]=chr3}}return output};




© 2015 - 2025 Weber Informatics LLC | Privacy Policy