Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
biguint-format
Advanced tools
Node.js module to format big uint numbers from a node Buffer, an array of bytes or a string in hex format to decimal, hexadecimal or octet string
JavaScript uses IEEE 754 double-precision floats to represents numbers. That works perfectly fine for small numbers, however, it is an issue for big integers. This means they lose integer precision for values beyond +/- 2 pow 53
Problem
Presentation of small integer in decimal format works fine (e.g. 0x1FF
). However, we can see an issue when try to convert big integers like 0x1234567890abcdeffedcba908765421
to string decimal.
(0x1FF).toString(10) // returns '511' - correct
(0x1234567890abcdeffedcba908765421).toString(10) // returns '1.5123660750094533e+36' - incorrect - lose integer precision
Solution
Node.js biguint-format
module has been built in order to help display very large unsigned integers without any integer precision lose. biguint-format
takes an array of bytes (values from 0 to 255) or node Buffer and converts it to decimal format.
var biguint = require('biguint-format');
// 0x1234567890abcdeffedcba908765421 split into bytes
biguint.toDecimalString([0x1, 0x23, 0x45, 0x67, 0x89, 0x0a, 0xbc, 0xde, 0xff, 0xed, 0xcb, 0xa9, 0x08, 0x76, 0x54, 0x21])
// output value is '1512366075009453296626403467035300897' - no integer precision lose
biguint-format
can also take array of bytes in Big Endian (BE
- default value) and Little Endian (LE
) formats. Check wikipedia for more details.
var biguint = require('biguint-format');
var buffer1 = new Buffer([0x63, 0xA7, 0x27]);
var buffer2 = new Buffer([0x27, 0xA7, 0x63]);
biguint.toDecimalString(buffer1, 'LE') // returns '2598755'
biguint.toDecimalString(buffer2, 'BE') // returns '2598755'
biguint.toDecimalString(buffer2) // returns '2598755'
FAQs
An arbitrary length unsigned integer formatter library for Node.js
The npm package biguint-format receives a total of 3,573 weekly downloads. As such, biguint-format popularity was classified as popular.
We found that biguint-format demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.