Node: feel like base32 encoding/decoding is missing

Created on 19 Aug 2018  Â·  8Comments  Â·  Source: nodejs/node

Would like for this to be possible:

str = buf.toString('base32')
buf = Buffer.from(str, 'base32')

I know there are npm packages for it but it feels like some easy fix for for the encoder/decoder to just restrict the table to a smaller alphabet

encoding feature request

Most helpful comment

Indeed it would be very useful to have such module in Node. Use case: TOTP.

All 8 comments

-1 I think extra encodings like that are best left out of core

@jimmywarting:

'base32' isn't directly supported here. But we still have Buffer.from and toString() methods.
So maybe you have to use npm a 3-rd party tool:
https://www.npmjs.com/package/encoding

There has been no follow-up here, and it’s clear that there’s opposition to adding this to core, as well as ecosystem modules that address this problem.

I’m closing this – if you want, we can re-open, but to be honest, I’m fairly confident that this feature is not going to be accepted.

Indeed it would be very useful to have such module in Node. Use case: TOTP.

NSEC3 presentation format

base58 for IPFS. Hooray! :)

Another good solution would be if you could just provide your own alphabet something like

str = buf.toString('abcABC123_')

then you can have any base you want.

+1 for HOTP & TOTP use cases

Been using https://github.com/emn178/hi-base32 for a while now and it works perfectly, but the non-breaking change ergonomics of having it built-in within the Buffer object could save us some brain cells, cpu cycles, and green-house gasses that we could instead collectively allot in other efforts that make the world a better place.

Was this page helpful?
0 / 5 - 0 ratings