Welcome to the Linux Foundation Forum!

Convert a String to base64 Encoded String by Using StringDecoder


I just solved the lab exercises for chapter 11 titled USING BUFFERS correctly and the tests pass

but as we learned in the chapter using .toString can result in encoding errors and its recommended to use StringDecoder

is there a way to use StringDecoder to do the conversion

another question that I have is about how assert.equal work here in this test, in particular, I understand the first value is the base64 string value of 'buffers are neat', but how was the second argument generated. just curious :)



  • videotechdude
    videotechdude Posts: 2
    edited June 14

    How did you solve it! I've been stuck on this for days! I tried using Buffer.from(str, 'base64'). I was trying to reverse engineer it as well with the assert statement but I could not figure out how to convert the assert either.

    oops just realized I posted in the answer area...
    Nevermind I found the answer on another post


Upcoming Training