Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
convert-x-to-y-bit-array
Advanced tools
Readme
Converts an array of X-bit unsigned integers to an array of Y-bit unsigned integers.
Limitations: Javascript bitwise operations work within 32 bits.
Import the function:
const convertXtoYbitarray = require("convert-x-to-y-bit-array");
Use the function:
/**
* Converts an array of X-bit unsigned integers to an array of Y-bit unsigned integers.
*
* @param {integer} Xbit - Number of bits each integer in the input array has
* @param {integer} Ybit - Number of bits each integer in the output array should have
* @param {integer[]} inputArray - Array of X-bit unsigned integers to convert
* @param {integer} [maxOutputLength] - Optional param to limit length of output array
*
* @return {integer[]} array of Y-bit unsigned integers
*/
convertXtoYbitarray(Xbit, Ybit, inputArray[, maxOutputLength])
const convertXtoYbitarray = require("convert-x-to-y-bit-array");
// Converts an array of 8-bit integers to an array of 12-bit integers
let result = convertXtoYbitarray(8, 12, [0, 1, 4, 16, 64]);
console.log(result);
// [ 0, 260, 260, 0 ]
[0, 1, 4, 16, 64]
represented as an array of 8-bit unsigned integers is:
00000000 00000001 00000100 00010000 01000000
When converting to an array of 12-bit unsigned integers, simply group the bits into groups of 12 (filling in the end with 0s):
000000000000 000100000100 000100000100 000000000000
Which is equivalent to [0, 260, 260, 0]
There are crazy people out there using 12-bit integers.
Create an issue or PR.
FAQs
Converts an array of X-bit unsigned integers to an array of Y-bit unsigned integers
We found that convert-x-to-y-bit-array demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).