Questions tagged [node.js-buffer]

9 questions
4
votes
1 answer

Python equivalent of Node.js Buffer.from('string', 'base64')

I'm trying to implement authorization based on a hash-based message authentication code (HMAC)-encrypted authorization header. To do so I need to use the authorization header to verify the authenticity of the message content by recalculating the…
flintpnz
  • 41
  • 3
3
votes
1 answer

Canonical way to remove multiple bytes from buffer

Say I have a simple Buffer in Node.js like so: const bytes = Buffer.from('abcdefg'); this buffer instance has slice and concat as methods, but I am really not sure how to use these to basically create the functionality of pop/shift/splice of an…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
2
votes
1 answer

How to send the buffer correctly in node.js via response.write?

I am trying to send out the binary content from a node.js server. To do this, I allocate a buffer and fill up the buffer with my content, and call response.write() on it. Once it returns, I reuse the buffer with the new content. However it doesn't…
George Y.
  • 11,307
  • 3
  • 24
  • 25
1
vote
0 answers

Cannot parse a PDF stream using pdf-parse on Azure pipelines (Nodejs)

We have an Nodejs api endpoint that creates a pdf stream using the html-pdf and streams it through the response. This is working as expected, we can download the pdf through the browser. I am trying to write a unit test (chai and mocha) for…
1
vote
0 answers

Creating an Image File using node.js buffer from input text

I have a requirement in which I need to convert an input text to a png/jpeg file and then convert to base64 string and send as an input to an API. I cannot use node.js fs module since I cannot physically create files. So I was trying to user…
Avinash
  • 2,003
  • 2
  • 17
  • 15
1
vote
2 answers

Node.js using deferent data types in bytes array

I need to create a byte array with deferent data types in it, For example: i will have data that will contain Byte (0-100), Byte(0-10), Two bytes(-30-+100), Bool(0/1), Byte, Two Bytes(0-300). The client will receive the bytes array (using Buffer)…
Erez
  • 1,933
  • 5
  • 29
  • 56
1
vote
0 answers

Raspberry pi USB serial transmission

I have problem with to the raspberry's usb serial tx direction. I use npm's serialport software with node.js. If I plug the usb cable (max232) with windows to serialmonitor, I can see the hex code (what I send from raspberry). But when I plug the…
Jdoe
  • 21
  • 2
0
votes
1 answer

Write array to Buffer on a specific offset in Node.js

I wish to add an array to a buffer at a specific offset. This does not work: let buffer = Buffer.alloc(65); buffer.writeUInt8(0x91, 0); buffer.write([127, 0, 0, 1 ], 1); buffer.write("admin", 5); buffer.write("admin", 31); as it gives me the…
robtot
  • 863
  • 1
  • 9
  • 31
-1
votes
1 answer

Why does using toString('binary') on a Node.js buffer give strange characters?

I have something similar to the following code: const fs = require('fs'); const imageBuffer = fs.readFileSync('path/to/image.jpg'); const binary = imageBuffer.toString('binary'); console.log(binary) Which gives something…
Jack
  • 397
  • 4
  • 13