Base64 efficiently decodes from buffer to buffer in node (node.js)

I currently have a version of python and C wsproxy (WebSockets for a simple TCP proxy) in noVNC . I would like to create a version of wsproxy using node.js. The key factor (and the reason why I’m not just using existing node WebSocket code) is that until the WebSocket standard is binary encoded, all traffic between wsproxy and the browser / client must be encoded (and base64 decodes / encodes quickly and easily in the browser).

Buffer types support base64, but this is from buffer to string and vice versa. How can I encode / decode base64 between two buffers without having to convert to a string first?

Limitations:

  • Direct Buffer to buffer (if you cannot show Buffer-> string-> Buffer as fast).
  • Since node has native base64 support, I would like to use this and not external modules .
  • In-place encoding / decoding within a single buffer is acceptable.

This discusses base64 support in node, but from what I see does not answer my question.

+3
source share
1 answer

, UTF-8, , , , , / UTF-8, , , , , .

0

Source: https://habr.com/ru/post/1771222/


All Articles