Skip to content

Instantly share code, notes, and snippets.

Michele Antonaci mantonaci

Block or report user

Report or block mantonaci

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
mantonaci / gist:10731724
Created Apr 15, 2014
Convert byte array to base64 string
View gist:10731724
var i2a = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'];
exports.base64_encode = function(s) {
var length = s.length;
var groupCount = Math.floor(length / 3);
var remaining = length - 3 * groupCount;
var result = "";
var idx = 0;
for (var i = 0; i < groupCount; i++) {
You can’t perform that action at this time.