How Can I Use Node.js Buffer Library In Client Side Javascript
I would like to use buffer library (in order handle binary data) in my website. here is my use case: const privateKey = Buffer.from('', 'hex'); buff
Solution 1:
Add standalone script to HTML from https://github.com/feross/buffer
<scriptsrc="https://bundle.run/buffer@6.0.3"></script>
Then in JS
const privateKey = buffer.Buffer.from(PRIVATE_KEY_1, "hex");
Solution 2:
The buffer object is not available outside of Node.js, i.e in the browser. This is because (in case you were not aware) Node.js is a javascript runtime, therefore Node.js specific functionalities do not exist within a browser environment, because they are associated with the V8 engine, but not the V8 engine within a browser (note the difference here).
So essentially, uncaught refernce error: buffer is not defined
means that this this doesn't exist in the browser.
Post a Comment for "How Can I Use Node.js Buffer Library In Client Side Javascript"