noseglid / base85

:sound: nodejs base85 encoding and decoding

Home Page:https://npmjs.com/base85

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Encode returning false

ajmas opened this issue · comments

I am running into an issue where base85.encode() is returning false. This is happening bother with a buffer and a text string. I am using Node 8.9.4.

For the text case:

base85.encode('hello world')

For the buffer it is one created by crypto.cipher

const iv = crypto.randomBytes(16);
const cipher = crypto.createCipheriv(algorithm, key, iv);
let encrypted = cipher.update(value, 'utf8');
encrypted = Buffer.concat([encrypted, cipher.final()]);

console.log(base85.encode(iv) + ',' + base85.encode(encrypted));

Here iv works fine, but not the encrypted buffer.

Note that 'ascii85' seems to work ok, but not 'z85'.

Rereading the docs I now see this is a limitation of the z85 specification, though I am wondering whether throwing an exception would not be better, than returning false?

This is super old, but I am experiencing this as well, and take it it hasn't been addressed - or a work around?