创建一个验证码 + 图片base64字符串流
489212
def create_image_base64():
    
    code, file = create_image()
    b64str = "data:image/png;base64,"
    with open(file, "rb") as f:
        if sys.version_info.major == 2:
            b64str += base64.b64encode(f.read())
        else:
            b64str += base64.b64encode(f.read()).decode()
    os.remove(file)
    return True, {"code": code, "base64": b64str}
119047
public static Binary fromBase64(String base64) {
        byte[] arr = Base64.decode(base64);
        return Binary.wrap(arr);
    }
810631
def decode_b64(data):
    ''''''
    byte_string = data.encode('utf-8')
    decoded = base64.b64decode(byte_string)
    return decoded.decode('utf-8')
62025
function fromBLC64(digits){
    var blc = "";
    for (var d=0, l=digits.length; d<l; ++d){
      var bits = base64Table[digits[d]];
      blc += d === 0 ? bits.slice(bits.indexOf("1")+1) : bits;
    };
    return fromBLC(blc);
  }
812566
function base64ToBytes(str) {
    if (typeof atob === 'undefined' && typeof Buffer === 'function') {
        // node.js doesn't have atob
        var buffer = Buffer.from(str, 'base64');
        return new Uint8Array(buffer);
    }
    var byteStr = atob(str);
    var arr = new Uint8Array(byteStr.length);
    for (var i = 0; i < byteStr.length; i++) {
        arr[i] = byteStr.charCodeAt(i);
    }
    return arr;
}
1183856
private String base64(String value)
    {
        StringBuffer cb = new StringBuffer();

        int i = 0;
        for (i = 0; i + 2 < value.length(); i += 3) {
            long chunk = (int) value.charAt(i);
            chunk = (chunk << 8) + (int) value.charAt(i + 1);
            chunk = (chunk << 8) + (int) value.charAt(i + 2);

            cb.append(encode(chunk >> 18));
            cb.append(encode(chunk >> 12));
            cb.append(encode(chunk >> 6));
            cb.append(encode(chunk));
        }

        if (i + 1 < value.length()) {
            long chunk = (int) value.charAt(i);
            chunk = (chunk << 8) + (int) value.charAt(i + 1);
            chunk <<= 8;

            cb.append(encode(chunk >> 18));
            cb.append(encode(chunk >> 12));
            cb.append(encode(chunk >> 6));
            cb.append('=');
        }
        else if (i < value.length()) {
            long chunk = (int) value.charAt(i);
            chunk <<= 16;

            cb.append(encode(chunk >> 18));
            cb.append(encode(chunk >> 12));
            cb.append('=');
            cb.append('=');
        }

        return cb.toString();
    }
1333292
public String toBase64() {
        return name
                + (checksum == null ? "null" : Base64.getDecoder().decode(checksum))
                + (lastModified == null ? "null" : lastModified);
    }
222501
function bytesToBase64(arr) {
    if (arr instanceof ArrayBuffer) {
        arr = new Uint8Array(arr);
    }
    if (typeof btoa === 'undefined' && typeof Buffer === 'function') {
        // node.js doesn't have btoa
        var buffer = Buffer.from(arr);
        return buffer.toString('base64');
    }
    var str = '';
    for (var i = 0; i < arr.length; i++) {
        str += String.fromCharCode(arr[i]);
    }
    return btoa(str);
}
1001794
function(bytes) {
      for (var base64 = [], i = 0; i < bytes.length; i += 3) {
        var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
        for (var j = 0; j < 4; j++)
          if (i * 8 + j * 6 <= bytes.length * 8)
            base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));
          else
            base64.push('=');
      }
      return base64.join('');
    }
161318
function urlToBase64 (url) {
  return new Promise((resolve, reject) => {
    request.get(url, (err, response, body) => {
      err && reject(err)
      resolve(body.toString('base64'))
    })
  })
}
648497
public static String base64ToString(String base64Value) {
        Utils.require(base64Value.length() % 4 == 0,
                      "Invalid base64 value (must be a multiple of 4 chars): " + base64Value);
        byte[] utf8String = DatatypeConverter.parseBase64Binary(base64Value);
        return toString(utf8String);
    }
37710
public static byte[] decodeBase64(String base64) {
    if (base64 == null)
      throw new NullPointerException("Parameter 'base64' cannot be null.");

    String fixedBase64 = padBase64(base64);
    return Base64.getDecoder().decode(fixedBase64);
  }
802170
def deserialize_base64(attr):
        
        if isinstance(attr, ET.Element):
            attr = attr.text
        padding = '=' * (3 - (len(attr) + 3) % 4)
        attr = attr + padding
        encoded = attr.replace('-', '+').replace('_', '/')
        return b64decode(encoded)
857192
function base64ArrayBuffer(bytes) {
    var base64    = ''
    var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'

    var byteLength    = bytes.byteLength
    var byteRemainder = byteLength % 3
    var mainLength    = byteLength - byteRemainder
   
    var a, b, c, d
    var chunk
   
    // Main loop deals with bytes in chunks of 3
    for (var i = 0; i < mainLength; i = i + 3) {
      // Combine the three bytes into a single integer
      chunk = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2]
   
      // Use bitmasks to extract 6-bit segments from the triplet
      a = (chunk & 16515072) >> 18 // 16515072 = (2^6 - 1) << 18
      b = (chunk & 258048)   >> 12 // 258048   = (2^6 - 1) << 12
      c = (chunk & 4032)     >>  6 // 4032     = (2^6 - 1) << 6
      d = chunk & 63               // 63       = 2^6 - 1
   
      // Convert the raw binary segments to the appropriate ASCII encoding
      base64 += encodings[a] + encodings[b] + encodings[c] + encodings[d]
    }
   
    // Deal with the remaining bytes and padding
    if (byteRemainder == 1) {
      chunk = bytes[mainLength]
   
      a = (chunk & 252) >> 2 // 252 = (2^6 - 1) << 2
   
      // Set the 4 least significant bits to zero
      b = (chunk & 3)   << 4 // 3   = 2^2 - 1
   
      base64 += encodings[a] + encodings[b] + '=='
    } else if (byteRemainder == 2) {
      chunk = (bytes[mainLength] << 8) | bytes[mainLength + 1]
   
      a = (chunk & 64512) >> 10 // 64512 = (2^6 - 1) << 10
      b = (chunk & 1008)  >>  4 // 1008  = (2^6 - 1) << 4
   
      // Set the 2 least significant bits to zero
      c = (chunk & 15)    <<  2 // 15    = 2^4 - 1
   
      base64 += encodings[a] + encodings[b] + encodings[c] + '='
    }
    
    return base64
  }
409936
function decode_base64(salt) {
        var decoded = new Array(16);
        var i = 0, j = 0, c1, c2;
        while(true) {
            c1 = index_64[salt.charCodeAt(i++)-46];
            c2 = index_64[salt.charCodeAt(i++)-46];
            decoded[j++] = (c1 << 2 | c2 >> 4) & 0xff;
            if (i === 22) break;
            
            c1 = c2 << 4;
            c2 = index_64[salt.charCodeAt(i++)-46];
            decoded[j++] = (c1 | c2 >> 2) & 0xff;

            c1 = c2 << 6;
            c2 = index_64[salt.charCodeAt(i++)-46];
            decoded[j++] = (c1 | c2) & 0xff;
        }
        return decoded;
    }
143530
private static StringBuilder toBase64(long value) {
		StringBuilder result = new StringBuilder(23); // Initialize with the size of ID if using Base64
		for(int shift=60; shift>=0; shift-=6) {
			result.append(Base64[(int)((value >> shift) & 0x3F)]);
		}
		return result;
	}
881462
function base64(url, obj, _, fn){
  if (3 == arguments.length) fn = _;
  var prefix = exports.prefix;
  obj = encode(JSON.stringify(obj));
  obj = encodeURIComponent(obj);
  url += '?' + prefix + '=' + obj;
  jsonp(url, { param: exports.callback }, function(err, obj){
    if (err) return fn(err);
    fn(null, {
      url: url,
      body: obj
    });
  });
}