Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Utility for converting numbers to/from different bases/alphabets. Common bases have convenience aliases (see below), but arbitrary/custom alphabets can be used.
On the server side w/ Node.js:
npm install bases
Or in the browser (adds a global Bases
variable for now):
<script src="bases.js"></script>
var bases = require('./bases');
// or window.Bases in the browser
bases.toBase16(200); // => 'c8'
bases.toBase62(99999); // => 'q0T'
bases.toAlphabet(300, 'aAbBcC'); // => 'Abba'
bases.fromBase16('c8'); // => 200
bases.fromBase62('q0T'); // => 99999
bases.fromAlphabet('Abba', 'aAbBcC'); // => 300
Going from numbers to strings:
toAlphabet(num, alphabet)
: returns a string representation of the given
number for the given alphabet, where the alphabet is an arbitrary string of
characters. (See known alphabets below for examples.)
toBase(num, base)
: convenience helper for known bases (see below).
toBaseX(num)
: convenience helpers for known bases (see below), e.g.
toBase62(num)
.
Going from strings to numbers:
fromAlphabet(str, alphabet)
: returns an integer representation of the given
string for the given alphabet.
fromBase(num, base)
: convenience helper for known bases.
fromBaseX(str)
: convenience helpers for known bases.
Numbers only:
Base-2 | 01 |
... | 012... |
Base-10 | 0123456789 |
Letters only:
Base-26 | abcdefghijklmnopqrstuvwxyz |
Base-52 | abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |
Alphanumeric:
Base-11 | 0123456789a |
... | 0123456789ab... |
Base-16 | 0123456789abcdef |
Base-36 | 0123456789abcdefghijklmnopqrstuvwxyz |
Base-62 | 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ |
Human-friendly:
Base-32 (from Douglas Crockford) | 0123456789ABCDEFGHJKMNPQRSTVWXYZ (no IOLU ) |
Base-58 (from Flickr) | 123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ (no 0lIO ) |
Other:
Base-64 (as standardized) | ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ |
Base-64 warning: besides there being several different standards, padding isn't currently added and line lengths aren't tracked. Not recommended for use with APIs that expect formal base-64 strings!
MIT license. (c) 2012-2014 Aseem Kishore and contributors.
FAQs
Utility for converting numbers to/from different bases/alphabets.
The npm package bases receives a total of 2,446 weekly downloads. As such, bases popularity was classified as popular.
We found that bases 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.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.