Encode / decode base32. Supports Buffers, strings, custom alphabets, abstract-encoding compliant
npm install base32-encodingbase32-encoding > Encode / decode base32. Supports Buffers, strings, custom alphabets, abstract-encoding compliant
``js
var base32 = require('base32-encoding')
var buf = crypto.randomBytes(32)
var b32 = base32.encode(buf)
var b256 = base32.decode(b32)
var str = base32.stringify(buf) // base32.encode then convert to string
var origBuf = base32.parse(str) // convert from string then base32.decode
`
Encode a normal Buffer as base32, meaning only the lower 5 bits are used.⌈len * 8 / 5⌉
Takes bytes to encode. Takes optional Buffer output insteadBuffer
of allocating a new internally, and writes at optional offset.output
Returns . Sets base32.encode.bytes to the number of bytes written.
Decode a base32 Buffer as a normal, "base256" Buffer, meaning only the lowerbuf
5 bits are read from and assembled into complete 8 bit bytes.⌊len * 5 / 8⌋
Takes bytes to encode. Takes optional Buffer output insteadBuffer
of allocating a new internally, and writes at optional offset.output
Returns . Sets base32.decode.bytes to the number of bytes written.
Returns ⌈len * 8 / 5⌉.
Encode buf to base32 and translate into a string using optional alphabet.alphabet defaults to 23456789abcdefghijkmnpqrstuvwxyz (missing o01l).
Decode str from base32 and translate from a string using optional alphabet.alphabet defaults to 23456789abcdefghijkmnpqrstuvwxyz (missing o01l).
`sh``
npm install base32-encoding