|
@ -68,12 +68,8 @@ function toByteArray (b64) { |
|
|
return arr |
|
|
return arr |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function encode (num) { |
|
|
|
|
|
return lookup[num] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function tripletToBase64 (num) { |
|
|
function tripletToBase64 (num) { |
|
|
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F) |
|
|
return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function encodeChunk (uint8, start, end) { |
|
|
function encodeChunk (uint8, start, end) { |
|
@ -104,15 +100,15 @@ function fromByteArray (uint8) { |
|
|
switch (extraBytes) { |
|
|
switch (extraBytes) { |
|
|
case 1: |
|
|
case 1: |
|
|
temp = uint8[uint8.length - 1] |
|
|
temp = uint8[uint8.length - 1] |
|
|
output += encode(temp >> 2) |
|
|
output += lookup[temp >> 2] |
|
|
output += encode((temp << 4) & 0x3F) |
|
|
output += lookup[(temp << 4) & 0x3F] |
|
|
output += '==' |
|
|
output += '==' |
|
|
break |
|
|
break |
|
|
case 2: |
|
|
case 2: |
|
|
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) |
|
|
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1]) |
|
|
output += encode(temp >> 10) |
|
|
output += lookup[temp >> 10] |
|
|
output += encode((temp >> 4) & 0x3F) |
|
|
output += lookup[(temp >> 4) & 0x3F] |
|
|
output += encode((temp << 2) & 0x3F) |
|
|
output += lookup[(temp << 2) & 0x3F] |
|
|
output += '=' |
|
|
output += '=' |
|
|
break |
|
|
break |
|
|
default: |
|
|
default: |
|
|