Unable to decode base64 encoded String within Node.js

19
April 15, 2019, at 11:10 AM

I'm trying to decode:

c2VxdWVuY2VEaWFncmFtCiAgICBwYXJ0aWNpcGFudCBBbGljZQogICAgcGFydGljaXBhbnQgQm9iCiAgICBBbGljZS0+Sm9objogSGVsbG8gSm9obiwgaG93IGFyZSB5b3U/CiAgICBsb29wIEhlYWx0aGNoZWNrCiAgICAgICAgSm9obi0+Sm9objogRmlnaHQgYWdhaW5zdCBoeXBvY2hvbmRyaWEKICAgIGVuZAogICAgTm90ZSByaWdodCBvZiBKb2huOiBSYXRpb25hbCB0aG91Z2h0cyA8YnIvPnByZXZhaWwuLi4KICAgIEpvaG4tLT5BbGljZTogR3JlYXQhCiAgICBKb2huLT5Cb2I6IEhvdyBhYm91dCB5b3U/CiAgICBCb2ItLT5Kb2huOiBKb2xseSBnb29kIQ==

Code

    let buff = Buffer.from(diagram, "base64").toString("utf-8");
    res.json({ data: buff });

Result

{"data":"sequenceDiagram\n participant Alice\n participant Bob\n Alice-\u0012��\u001b��\u0012\u0019[\u001b\u001b�\u0012��\u001b�\b\u001a\u001b��\u0018\�H\u001e[�O\b\b\b\u001b\u001b��\b\u0012\u0019X[\u001d\u001a\u0018�\u0019X�\b\b\b\b\b\b\b\u0012��\u001b�D����\u0004f�v�B\u0006\u0016v\u0016��7B\u0006��\u0006�6���G&�\u0010�\u0002\u0002\u0002\u0006V�@�\u0002\u0002\u0002\u0004��FR\u0007&�v�B\u0006�b\u0004����\u0005&\u0017F���\u0016�\u0007F��Vv�G2\u0003�'\"��\u0007&Wf\u0016�����\u0002\u0002\u0002\u0004�������\u0016Ɩ6S�\u0004w&V\u0017B\u0010�\u0002\u0002\u0002\u0004������&�#�\u0004��r\u0006\u0016&�WB\u0007��S�\u0002\u0002\u0002\u0004&�\"������\u0004���ǒ\u0006v��B\u0010"}

If I run this through an online tool, it looks fine. What am I doing wrong?

Desired Result

sequenceDiagram
    participant Alice
    participant Bob
    Alice->John: Hello John, how are you?
    loop Healthcheck
        John->John: Fight against hypochondria
    end
    Note right of John: Rational thoughts <br/>prevail...
    John-->Alice: Great!
    John->Bob: How about you?
    Bob-->John: Jolly good!
READ ALSO
I keep getting the error &ldquo;the string did not match the expected pattern&rdquo; for my fetch request

I keep getting the error “the string did not match the expected pattern” for my fetch request

I keep getting the error "the string did not match the expected pattern" for my fetch requestsI've seen some people having similar problems on here and other forums but can't pinpoint the problem

21
Unable to pass parameter to inline javascript via ng-include

Unable to pass parameter to inline javascript via ng-include

I'm trying to build a AngularJS application with few dynamic html templates using ng-includeThese html's contain inline javascript with a variable

36
Add black bar to an ion-card

Add black bar to an ion-card

I have an ion-card with a header (title and subtitle) and I need to add a black bar on top of the header

44
What is the fastest way I can determine whether the intersection of multiple sets of integers is nonempty?

What is the fastest way I can determine whether the intersection of multiple sets of integers is nonempty?

I am part of a undergrad mathematics groupI have a collection of sets of unique integers (sets are varying length)

42