0

I have an array with bytes and need them to be in StringBase64 and I am using the following:

var base64String = btoa(String.fromCharCode.apply(null, new Uint8Array(arrayDigestion)));
console.log('digestionB64_2 .......:' + digestionB64);

with the following result:

digestionB64_2 .......:6d9310a8df39348ef2bbd8a0f04f65bba64180666848526a4c93e86aa69433e7

And I've also used the following code and get the same results no difference whatsoever:

function arrayBufferToString(buffer) {
    var binary = '';
    var bytes = new Uint8Array( buffer );
    var len = bytes.byteLength;
    for (var i = 0; i < len; i++) {
        binary += String.fromCharCode( bytes[ i ] );
    }
    return binary;
}

As I understand Strings in Base 64 must end with an = or == characters

Would it be valid if I add those characters manually at the end or is it valid to have a StringBase64 without them?

lumee
  • 613
  • 1
  • 5
  • 15

0 Answers0