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.
Use an array of multi-character alphanumeric symbols to convert bases exceeding 62
Use an array of multi-character alphanumeric symbols to convert between bases exceeding 62.
var basek = require('basek');
<script src='basek.min.js'></script> // var basek = Basek()
===
The default alphabet is 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
which supports all base conversions up to 62.
basek.base10to2(15) // "1111"
basek.base10to16(15) // "f"
basek.base16to10("f") // "15"
basek.base2to10(1111) // "15"
basek.makeTag(2,16)
// Basek.prototype.base2to16 and Basek.prototype.base16to2 are now defined
basek.base2to16(1111) // "f"
basek.base16to2("f") // "1111"
Convert to/from decimal using these generics. If you don't provide a base parameter, Basek uses the length of your alphabet to determine the base.
basek.toBase(61).get() // "Z"
basek.toBase(61,2).get() // "111110"
basek.fromBase("Z").get() // "61"
basek.fromBase("ff",16).get() // "255"
You can literally use any combination of multi-character symbols to extend Basek's alphabetic representation and thus extending your base limit. First here's some basic usage.
// Using only single character symbols
basek.alpha()
// '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' - default base62
basek.alphaExtend('%^')
// '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%^' - base64
basek.alphaSet()
// '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' - back to default
basek.alphaSet('abcdefghijklmnopqrstuvwzyz')
// 'abcdefghijklmnopqrstuvwzyz' - alphabet set
basek.toBase(15,2).get() // 'bbbb'
Now using multi-character alphanumeric symbols to extend Basek's base range to 100
basek.alphaSet() // '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' - back to default
for (var i = 0; i < 38; i++) {
basek.alphaExtend(['a'+i]);
} // alphabet set to Array[100] (['0','1',...,'a37'])
basek.toBase(99).get() // 'a37' - your multi-character symbol representing decimal 99 in base100
Use pad to prepend n bits (bit = character at the 0th index of your alphabet) to your string and unpad to slice the representation back to its original glory.
basek.alphaSet()
basek.toBase(15,2) // '1111'
basek.pad(10) // '0000001111'
basek.unpad() // '1111'
Chain several functions together
basek.alphaSet('ab').toBase(10).pad(10).get() // 'aaaaaababa'
MIT
FAQs
Use an array of multi-character alphanumeric symbols to convert bases exceeding 62
The npm package basek receives a total of 6 weekly downloads. As such, basek popularity was classified as not popular.
We found that basek 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.