Search code examples
javascriptstringguidascii

How can I convert a Guid to a Byte array in Javascript?


I have a service bus, and the only way to transform data is via JavaScript. I need to convert a Guid to a byte array so I can then convert it to Ascii85 and shrink it into a 20 character string for the receiving customer endpoint.

Any thoughts would be appreciated.


Solution

  • This is a VERY old question but it shows up top of google search results so here is the new age correct answer.

    Buffer.from(guid.replaceAll('-',''), 'hex')