New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ascii85

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ascii85 - npm Package Compare versions

Comparing version

to
1.0.0

178

index.js

@@ -7,2 +7,43 @@ /**

// Buffer api is changed since v6.0.0. this wrapper is designed to leverage new
// api features if possible without breaking old node.
//
// it's not a completed polyfill implementation. i just do necessary shims for this
// package only.
var _BufferFrom = Buffer.from || function() {
switch (arguments.length) {
case 1: return new Buffer(arguments[0]);
case 2: return new Buffer(arguments[0], arguments[1]);
case 3: return new Buffer(arguments[0], arguments[1], arguments[2]);
default: throw new Exception('unexpected call.');
}
};
var _BufferAlloc = Buffer.alloc || function(size, fill, encoding) {
var buf = new Buffer(size);
if (fill !== undefined) {
if (typeof encoding === "string") {
buf.fill(fill, encoding);
} else {
buf.fill(fill);
}
}
return buf;
};
var _BufferAllocUnsafe = Buffer.allocUnsafe || function(size) {
return new Buffer(size);
};
var _NewUint8Array = (function() {
if (typeof Uint8Array === 'undefined') {
return function(size) {
return new Array(size);
};
} else {
return function(size) {
return new Uint8Array(size);
}
}
})();
var ASCII85_BASE = 85;

@@ -16,6 +57,10 @@ var ASCII85_CODE_START = 33;

var ASCII85_PADDING_VALUE = 'u'.charCodeAt(0);
var ASCII85_ENCODING_GROUP_LENGTH = 4;
var ASCII85_DECODING_GROUP_LENGTH = 5;
var ASCII85_BLOCK_START = '<~';
var ASCII85_BLOCK_START_VALUE = (new Buffer(ASCII85_BLOCK_START)).readInt16BE(0);
var ASCII85_BLOCK_START_LENGTH = ASCII85_BLOCK_START.length;
var ASCII85_BLOCK_START_VALUE = _BufferFrom(ASCII85_BLOCK_START).readUInt16BE(0);
var ASCII85_BLOCK_END = '~>';
var ASCII85_BLOCK_END_VALUE = (new Buffer(ASCII85_BLOCK_END)).readInt16BE(0);
var ASCII85_BLOCK_END_LENGTH = ASCII85_BLOCK_END.length;
var ASCII85_BLOCK_END_VALUE = _BufferFrom(ASCII85_BLOCK_END).readUInt16BE(0);
var ASCII85_GROUP_SPACE = 'y';

@@ -89,10 +134,11 @@ var ASCII85_GROUP_SPACE_VALUE = ASCII85_GROUP_SPACE.charCodeAt(0);

Ascii85.prototype.encode = function(data, options) {
var bytes = new Array(5);
var output = [];
var bytes = _NewUint8Array(5);
var buf = data;
var defOptions = this._options;
var table, delimiter, groupSpace, digits, cur, i, j, r, b, len, padding;
var output, offset, table, delimiter, groupSpace, digits, cur, i, j, r, b, len, padding;
if (!(buf instanceof Buffer)) {
buf = new Buffer(buf, 'binary');
if (typeof buf === "string") {
buf = _BufferFrom(buf, 'binary');
} else if (!(buf instanceof Buffer)) {
buf = _BufferFrom(buf);
}

@@ -123,15 +169,22 @@

// estimate output length and alloc buffer for it.
offset = 0;
len = Math.ceil(buf.length * ASCII85_DECODING_GROUP_LENGTH / ASCII85_ENCODING_GROUP_LENGTH) +
ASCII85_ENCODING_GROUP_LENGTH +
(delimiter? ASCII85_BLOCK_START_LENGTH + ASCII85_BLOCK_END_LENGTH: 0);
output = _BufferAllocUnsafe(len);
if (delimiter) {
output.push(ASCII85_BLOCK_START);
offset += output.write(ASCII85_BLOCK_START, offset);
}
// iterate over all data bytes.
for (i = digits = cur = 0, len = buf.length; i < len; i++) {
b = buf.readUInt8(i);
cur *= 1 << 8;
cur += b;
digits++;
if (digits % 4) {
if (digits % ASCII85_ENCODING_GROUP_LENGTH) {
continue;

@@ -141,5 +194,5 @@ }

if (groupSpace && cur === ASCII85_GROUP_SPACE_CODE) {
output.push(ASCII85_GROUP_SPACE);
offset += output.write(ASCII85_GROUP_SPACE, offset);
} else if (cur) {
for (j = 4; j >= 0; j--) {
for (j = ASCII85_ENCODING_GROUP_LENGTH; j >= 0; j--) {
r = cur % ASCII85_BASE;

@@ -150,23 +203,23 @@ bytes[j] = r;

for (j = 0; j < 5; j++) {
output.push(table[bytes[j]]);
for (j = 0; j < ASCII85_DECODING_GROUP_LENGTH; j++) {
offset += output.write(table[bytes[j]], offset);
}
} else {
output.push(ASCII85_ZERO);
offset += output.write(ASCII85_ZERO, offset);
}
cur = 0;
digits = 0;
}
// add padding for remaining bytes.
if (digits) {
if (cur) {
padding = 4 - digits;
padding = ASCII85_ENCODING_GROUP_LENGTH - digits;
for (i = 4 - digits; i > 0; i--) {
for (i = ASCII85_ENCODING_GROUP_LENGTH - digits; i > 0; i--) {
cur *= 1 << 8;
}
for (j = 4; j >= 0; j--) {
for (j = ASCII85_ENCODING_GROUP_LENGTH; j >= 0; j--) {
r = cur % ASCII85_BASE;

@@ -177,7 +230,7 @@ bytes[j] = r;

for (j = 0; j < 5; j++) {
output.push(table[bytes[j]]);
for (j = 0; j < ASCII85_DECODING_GROUP_LENGTH; j++) {
offset += output.write(table[bytes[j]], offset);
}
output = output.slice(0, output.length - padding);
offset -= padding;
} else {

@@ -187,12 +240,12 @@ // If remaining bytes are zero, need to insert '!' instead of 'z'.

for (i = 0; i < digits + 1; i++) {
output.push(table[0]);
offset += output.write(table[0], offset);
}
}
}
if (delimiter) {
output.push('~>');
offset += output.write(ASCII85_BLOCK_END, offset);
}
return output.join('');
return output.slice(0, offset);
};

@@ -207,6 +260,5 @@

Ascii85.prototype.decode = function(str, table) {
var output = '';
var defOptions = this._options;
var buf = str;
var digits, cur, i, c, t, len, padding;
var output, offset, digits, cur, i, c, t, len, padding;

@@ -228,19 +280,40 @@ table = table || defOptions.decodingTable || ASCII85_DEFAULT_DECODING_TABLE;

if (!(buf instanceof Buffer)) {
buf = new Buffer(buf);
buf = _BufferFrom(buf);
}
// estimate output length and alloc buffer for it.
for (i = 0, t = 0, len = buf.length; i < len; i++) {
c = buf.readUInt8(i);
if (c === ASCII85_ZERO_VALUE || c === ASCII85_GROUP_SPACE_VALUE) {
t++;
}
}
offset = 0;
len = Math.ceil(buf.length * ASCII85_ENCODING_GROUP_LENGTH / ASCII85_DECODING_GROUP_LENGTH) +
t * ASCII85_ENCODING_GROUP_LENGTH +
ASCII85_DECODING_GROUP_LENGTH;
output = _BufferAllocUnsafe(len);
// if str starts with delimiter ('<~'), it must end with '~>'.
if (buf.length >= 4 && buf.readInt16BE(0) === ASCII85_BLOCK_START_VALUE) {
if (buf.readInt16BE(buf.length - 2) !== ASCII85_BLOCK_END_VALUE) {
if (buf.length >= ASCII85_BLOCK_START_LENGTH + ASCII85_BLOCK_END_LENGTH && buf.readUInt16BE(0) === ASCII85_BLOCK_START_VALUE) {
for (i = buf.length - ASCII85_BLOCK_END_LENGTH; i > ASCII85_BLOCK_START_LENGTH; i--) {
if (buf.readUInt16BE(i) === ASCII85_BLOCK_END_VALUE) {
break;
}
}
if (i <= ASCII85_BLOCK_START_LENGTH) {
throw new Error('Invalid ascii85 string delimiter pair.');
}
buf = buf.slice(2, buf.length - 2);
buf = buf.slice(ASCII85_BLOCK_START_LENGTH, i);
}
for (i = digits = cur = 0, len = buf.length; i < len; i++) {
for (i = digits = cur = 0, len = buf.length; i < len; i++) {
c = buf.readUInt8(i);
if (c === ASCII85_ZERO_VALUE) {
output += ASCII85_NULL_STRING;
offset += output.write(ASCII85_NULL_STRING, offset);
continue;

@@ -250,6 +323,6 @@ }

if (c === ASCII85_GROUP_SPACE_VALUE) {
output += ASCII85_GROUP_SPACE_STRING;
offset += output.write(ASCII85_GROUP_SPACE_STRING, offset);
continue;
}
if (table[c] === undefined) {

@@ -262,18 +335,15 @@ continue;

digits++;
if (digits % 5) {
if (digits % ASCII85_DECODING_GROUP_LENGTH) {
continue;
}
output += String.fromCharCode((cur >>> 24) & 0xFF);
output += String.fromCharCode((cur >>> 16) & 0xFF);
output += String.fromCharCode((cur >>> 8) & 0xFF);
output += String.fromCharCode(cur & 0xFF);
offset = output.writeUInt32BE(cur, offset);
cur = 0;
digits = 0;
}
if (digits) {
padding = 5 - digits;
padding = ASCII85_DECODING_GROUP_LENGTH - digits;
for (i = 0; i < padding; i++) {

@@ -285,7 +355,7 @@ cur *= ASCII85_BASE;

for (i = 3, len = padding - 1; i > len; i--) {
output += String.fromCharCode((cur >>> (i * 8)) & 0xFF);
offset = output.writeUInt8((cur >>> (i * 8)) & 0xFF, offset);
}
}
return output;
return output.slice(0, offset);
};

@@ -292,0 +362,0 @@

{
"name": "ascii85",
"version": "0.1.0",
"version": "1.0.0",
"engines" : {
"node" : ">=0.12"
},
"description": "Ascii85 (a.k.a. base85) encoding/decoding.",

@@ -5,0 +8,0 @@ "main": "index.js",

# Ascii85 (Base85) Encoding/Decoding #
[![Build Status](https://travis-ci.org/huandu/node-ascii85.svg?branch=master)](https://travis-ci.org/huandu/node-ascii85)
[Ascii85](http://en.wikipedia.org/wiki/Ascii85), also called Base85, is a form of binary-to-text encoding. By using five ASCII characters to represent four bytes of binary data, it is more efficient than uuencode or Base64, which use four characters to represent three bytes of data. See [ascii85 wikipedia page](http://en.wikipedia.org/wiki/Ascii85) for more details.
This node module can encode any binary string/buffer to an ascii85 string and decode an encoded string back to data.
This node module can encode any binary string/buffer to an ascii85 `Buffer` and decode encoded string back to original data.

@@ -19,4 +21,4 @@ ## Install ##

str === 'ARTY*'; // true
ascii85.decode(str) === 'easy'; // true
str.toString() === 'ARTY*'; // true
ascii85.decode(str).toString() === 'easy'; // true
```

@@ -28,6 +30,7 @@

Encode a binary data to ascii85 string.
Encode a string or `Buffer`.
* `data` is a string or a `Buffer`.
* `options` is optional. If it's provided, it can be an array of character or an option object.
* Return a `Buffer` with encoded data.

@@ -38,6 +41,6 @@ See following sample for detail.

var ascii85 = require('ascii85');
var str;
var buf;
// Most common use.
str = ascii85.encode('easy');
buf = ascii85.encode('easy');

@@ -47,5 +50,5 @@ // Provide an array of charaters to encode the string.

// with a customized ascii85 encoding, e.g. ZeroMQ flavor.
str = ascii85.encode('easy', ['0', '1', '2', ...]);
buf = ascii85.encode('easy', ['0', '1', '2', ...]);
str = ascii85.encode('easy', {
buf = ascii85.encode('easy', {
table: [...], // an array of characters to encode the string

@@ -59,6 +62,7 @@ delimiter: false, // result will be sorrounded by '<~' and '~>'

Decode a string to binary string.
Decode a ascii85-encoded string or `Buffer`.
* `str` is a string or a `Buffer`. All invalid characters will be discarded. If `str` starts with `<~`, it must have `~>` at the end. Otherwise, an error will be thrown.
* `table` is a sparse array to map char code to decoded value for decoding.
* Return a `Buffer` with decoded data.

@@ -96,3 +100,3 @@ See following sample for detail.

PostScript.encode('easy') === '<~ARTY*~>'; // true
PostScript.encode('easy').toString() === '<~ARTY*~>'; // true
```

@@ -106,3 +110,3 @@

var ZeroMQ = require('ascii85').ZeroMQ;
ZeroMQ.encode('easy') === 'wNPU9'; // true
ZeroMQ.encode('easy').toString() === 'wNPU9'; // true
```

@@ -116,3 +120,3 @@

var PostScript = require('ascii85').PostScript;
PostScript.encode('easy') === '<~ARTY*~>'; // true
PostScript.encode('easy').toString() === '<~ARTY*~>'; // true
```

@@ -119,0 +123,0 @@

@@ -8,34 +8,34 @@ 'use strict';

it('decodes "easy"', function() {
expect(ascii85.decode('<~ARTY*~>')).to.equal('easy');
expect(ascii85.decode('<~ARTY*~>').toString()).to.equal('easy');
});
it('decodes "moderate"', function() {
expect(ascii85.decode('<~D/WrrEaa\'$~>')).to.equal('moderate');
expect(ascii85.decode('<~D/WrrEaa\'$~>').toString()).to.equal('moderate');
});
it('decodes "somewhat difficult"', function() {
expect(ascii85.decode('<~F)Po,GA(E,+Co1uAnbatCif~>')).to.equal('somewhat difficult');
expect(ascii85.decode('<~F)Po,GA(E,+Co1uAnbatCif~>').toString()).to.equal('somewhat difficult');
});
it('decodes " "', function() {
expect(ascii85.decode('<~+<VdL+<VdL+9~>')).to.equal(' ');
expect(ascii85.decode('<~yy+9~>')).to.equal(' ');
expect(ascii85.decode('<~+<VdL+<VdL+9~>').toString()).to.equal(' ');
expect(ascii85.decode('<~yy+9~>').toString()).to.equal(' ');
});
it('decodes zeros', function() {
expect(ascii85.decode('<~!!~>')).to.equal('\0');
expect(ascii85.decode('<~!!!~>')).to.equal('\0\0');
expect(ascii85.decode('<~!!!!~>')).to.equal('\0\0\0');
expect(ascii85.decode('<~z~>')).to.equal('\0\0\0\0');
expect(ascii85.decode('<~z!!~>')).to.equal('\0\0\0\0\0');
expect(ascii85.decode('<~!!~>').toString()).to.equal('\0');
expect(ascii85.decode('<~!!!~>').toString()).to.equal('\0\0');
expect(ascii85.decode('<~!!!!~>').toString()).to.equal('\0\0\0');
expect(ascii85.decode('<~z~>').toString()).to.equal('\0\0\0\0');
expect(ascii85.decode('<~z!!~>').toString()).to.equal('\0\0\0\0\0');
});
it('decodes binary', function() {
expect(ascii85.encode('\x60\xD1\x05\x8B\x3D\xB2\xB4\x71\x5A\x66\x5B\x05\xC3\xC7\x14\x1C\x4F\x3D\x17\x1E\x5F\x0C\x68'))
expect(ascii85.encode('\x60\xD1\x05\x8B\x3D\xB2\xB4\x71\x5A\x66\x5B\x05\xC3\xC7\x14\x1C\x4F\x3D\x17\x1E\x5F\x0C\x68').toString())
.to.equal('@*o.94gMG7>%UtB_oEH2:H]L8?OUT');
expect(ascii85.encode('\x5F\xAA\x7A\xDB\x06\x63\xC5\x43\xD8\xE3\x89\x4F\xC3\xCF\x17\x90\x4E\x0A\xA8\x6E\x86\x73\xD4\x9C\x49\xBC\x94\xA3\x6A\x59\xC3\xC4\xE5\x81\xBF\x03\x97\xB5\x29\x33\xF2\xD5'))
expect(ascii85.encode('\x5F\xAA\x7A\xDB\x06\x63\xC5\x43\xD8\xE3\x89\x4F\xC3\xCF\x17\x90\x4E\x0A\xA8\x6E\x86\x73\xD4\x9C\x49\xBC\x94\xA3\x6A\x59\xC3\xC4\xE5\x81\xBF\x03\x97\xB5\x29\x33\xF2\xD5').toString())
.to.equal('?`JG,#%PV>f].fa_p9-\\:(!q;L3(k78\\C:_C0AHmjak/KQaJ7uo$m');
expect(ascii85.encode('\xBB\xE1\xF6\x43\xD4\xDA\x18\x52\x85\x3E\x45\xD5\x61\x6E\xCD\x41\x4C\x05\xEB\x29\xC9\x11\xA1\x11\xEF\x29\xCB\x95\xBF\x7E\xAB\x93\x6F\x96\x08\xC3\x96\x3B\x86\x32\xC4\xD1'))
expect(ascii85.encode('\xBB\xE1\xF6\x43\xD4\xDA\x18\x52\x85\x3E\x45\xD5\x61\x6E\xCD\x41\x4C\x05\xEB\x29\xC9\x11\xA1\x11\xEF\x29\xCB\x95\xBF\x7E\xAB\x93\x6F\x96\x08\xC3\x96\x3B\x86\x32\xC4\xD1').toString())
.to.equal(']A`HNeCka;Kg%rU@;a=U9Ej`2aUt3YmjZGF^OE5IDjC[HQ90gV`6e');
expect(ascii85.encode('\x6F\xA7\xA0\xFF\x53\x4D\x5D\x9E\xBD\xA7\x51\x9A\x16\xFE\x14\xB4\xB0\x16\x7E\x0C\x97\x3E\xC7\xD3\x44\xE5\xD0\x94\xA7\xF0\xA2\x3B\x0D\x23\xEC\x58\xD0\x01\xF7\x4A\x25\xCD\xA3\x03\xC1\xDE\xB7\xDA\x99\x1D\xF9\xA0\xA2\x66\x52\x40\xF1\x54\xDA\x55\x8F\x0B\x89\xDC\x72\x61\xAC\x6E\xB9\xAB\x42\xC7\x97\x0F\x61\x46\x0F\x75\xF9\x73'))
expect(ascii85.encode('\x6F\xA7\xA0\xFF\x53\x4D\x5D\x9E\xBD\xA7\x51\x9A\x16\xFE\x14\xB4\xB0\x16\x7E\x0C\x97\x3E\xC7\xD3\x44\xE5\xD0\x94\xA7\xF0\xA2\x3B\x0D\x23\xEC\x58\xD0\x01\xF7\x4A\x25\xCD\xA3\x03\xC1\xDE\xB7\xDA\x99\x1D\xF9\xA0\xA2\x66\x52\x40\xF1\x54\xDA\x55\x8F\x0B\x89\xDC\x72\x61\xAC\x6E\xB9\xAB\x42\xC7\x97\x0F\x61\x46\x0F\x75\xF9\x73').toString())
.to.equal('Dl99.;b^Ph]r+_r(B,#TYSMZrQTiI=7-2d[VspEB%3t4AciNl5--`1e_;;ZTR2u*rU1R:gnPn4BNsgg"Eac%e\\Z8\';QOdLo%s@\\h');

@@ -45,5 +45,9 @@ });

it('ignores blanks', function() {
expect(ascii85.decode('<~ A\tR\nT\rY*~>')).to.equal('easy');
expect(ascii85.decode('<~ A\tR\nT\rY*~>').toString()).to.equal('easy');
});
it('ignores extra characters at tail', function() {
expect(ascii85.decode('<~ A R T Y*~>abc deg').toString()).to.equal('easy');
});
it('throws when delimiter does not match', function() {

@@ -50,0 +54,0 @@ expect(ascii85.decode.bind('<~ARTY*~')).to.throw(Error);

@@ -8,38 +8,38 @@ 'use strict';

it('encodes "easy"', function() {
expect(ascii85.encode('easy')).to.equal('ARTY*');
expect(ascii85.encode('easy').toString()).to.equal('ARTY*');
});
it('encodes "easy" without delimiter', function() {
expect(ascii85.encode('easy', {delimiter: true})).to.equal('<~ARTY*~>');
expect(ascii85.encode('easy', {delimiter: true}).toString()).to.equal('<~ARTY*~>');
});
it('encodes "moderate"', function() {
expect(ascii85.encode('moderate')).to.equal('D/WrrEaa\'$');
expect(ascii85.encode('moderate').toString()).to.equal('D/WrrEaa\'$');
});
it('encodes "somewhat difficult"', function() {
expect(ascii85.encode('somewhat difficult')).to.equal('F)Po,GA(E,+Co1uAnbatCif');
expect(ascii85.encode('somewhat difficult').toString()).to.equal('F)Po,GA(E,+Co1uAnbatCif');
});
it('encodes " "', function() {
expect(ascii85.encode(' ')).to.equal('+<VdL+<VdL+9');
expect(ascii85.encode(' ', {groupSpace: true})).to.equal('yy+9');
expect(ascii85.encode(' ').toString()).to.equal('+<VdL+<VdL+9');
expect(ascii85.encode(' ', {groupSpace: true}).toString()).to.equal('yy+9');
});
it('encodes zeros', function() {
expect(ascii85.encode('\0')).to.equal('!!');
expect(ascii85.encode('\0\0')).to.equal('!!!');
expect(ascii85.encode('\0\0\0')).to.equal('!!!!');
expect(ascii85.encode('\0\0\0\0')).to.equal('z');
expect(ascii85.encode('\0\0\0\0\0')).to.equal('z!!');
expect(ascii85.encode('\0').toString()).to.equal('!!');
expect(ascii85.encode('\0\0').toString()).to.equal('!!!');
expect(ascii85.encode('\0\0\0').toString()).to.equal('!!!!');
expect(ascii85.encode('\0\0\0\0').toString()).to.equal('z');
expect(ascii85.encode('\0\0\0\0\0').toString()).to.equal('z!!');
});
it('encodes binary', function() {
expect(ascii85.encode('\x60\xD1\x05\x8B\x3D\xB2\xB4\x71\x5A\x66\x5B\x05\xC3\xC7\x14\x1C\x4F\x3D\x17\x1E\x5F\x0C\x68'))
expect(ascii85.encode('\x60\xD1\x05\x8B\x3D\xB2\xB4\x71\x5A\x66\x5B\x05\xC3\xC7\x14\x1C\x4F\x3D\x17\x1E\x5F\x0C\x68').toString())
.to.equal('@*o.94gMG7>%UtB_oEH2:H]L8?OUT');
expect(ascii85.encode('\x5F\xAA\x7A\xDB\x06\x63\xC5\x43\xD8\xE3\x89\x4F\xC3\xCF\x17\x90\x4E\x0A\xA8\x6E\x86\x73\xD4\x9C\x49\xBC\x94\xA3\x6A\x59\xC3\xC4\xE5\x81\xBF\x03\x97\xB5\x29\x33\xF2\xD5'))
expect(ascii85.encode('\x5F\xAA\x7A\xDB\x06\x63\xC5\x43\xD8\xE3\x89\x4F\xC3\xCF\x17\x90\x4E\x0A\xA8\x6E\x86\x73\xD4\x9C\x49\xBC\x94\xA3\x6A\x59\xC3\xC4\xE5\x81\xBF\x03\x97\xB5\x29\x33\xF2\xD5').toString())
.to.equal('?`JG,#%PV>f].fa_p9-\\:(!q;L3(k78\\C:_C0AHmjak/KQaJ7uo$m');
expect(ascii85.encode('\xBB\xE1\xF6\x43\xD4\xDA\x18\x52\x85\x3E\x45\xD5\x61\x6E\xCD\x41\x4C\x05\xEB\x29\xC9\x11\xA1\x11\xEF\x29\xCB\x95\xBF\x7E\xAB\x93\x6F\x96\x08\xC3\x96\x3B\x86\x32\xC4\xD1'))
expect(ascii85.encode('\xBB\xE1\xF6\x43\xD4\xDA\x18\x52\x85\x3E\x45\xD5\x61\x6E\xCD\x41\x4C\x05\xEB\x29\xC9\x11\xA1\x11\xEF\x29\xCB\x95\xBF\x7E\xAB\x93\x6F\x96\x08\xC3\x96\x3B\x86\x32\xC4\xD1').toString())
.to.equal(']A`HNeCka;Kg%rU@;a=U9Ej`2aUt3YmjZGF^OE5IDjC[HQ90gV`6e');
expect(ascii85.encode('\x6F\xA7\xA0\xFF\x53\x4D\x5D\x9E\xBD\xA7\x51\x9A\x16\xFE\x14\xB4\xB0\x16\x7E\x0C\x97\x3E\xC7\xD3\x44\xE5\xD0\x94\xA7\xF0\xA2\x3B\x0D\x23\xEC\x58\xD0\x01\xF7\x4A\x25\xCD\xA3\x03\xC1\xDE\xB7\xDA\x99\x1D\xF9\xA0\xA2\x66\x52\x40\xF1\x54\xDA\x55\x8F\x0B\x89\xDC\x72\x61\xAC\x6E\xB9\xAB\x42\xC7\x97\x0F\x61\x46\x0F\x75\xF9\x73'))
expect(ascii85.encode('\x6F\xA7\xA0\xFF\x53\x4D\x5D\x9E\xBD\xA7\x51\x9A\x16\xFE\x14\xB4\xB0\x16\x7E\x0C\x97\x3E\xC7\xD3\x44\xE5\xD0\x94\xA7\xF0\xA2\x3B\x0D\x23\xEC\x58\xD0\x01\xF7\x4A\x25\xCD\xA3\x03\xC1\xDE\xB7\xDA\x99\x1D\xF9\xA0\xA2\x66\x52\x40\xF1\x54\xDA\x55\x8F\x0B\x89\xDC\x72\x61\xAC\x6E\xB9\xAB\x42\xC7\x97\x0F\x61\x46\x0F\x75\xF9\x73').toString())
.to.equal('Dl99.;b^Ph]r+_r(B,#TYSMZrQTiI=7-2d[VspEB%3t4AciNl5--`1e_;;ZTR2u*rU1R:gnPn4BNsgg"Eac%e\\Z8\';QOdLo%s@\\h');

@@ -49,8 +49,8 @@ });

it('encodes data using ZeroMQ flavor', function() {
expect(ascii85.ZeroMQ.encode('easy')).to.equal('wNPU9');
expect(ascii85.ZeroMQ.encode('easy').toString()).to.equal('wNPU9');
});
it('encodes data using PostScript flavor', function() {
expect(ascii85.PostScript.encode('easy')).to.equal('<~ARTY*~>');
expect(ascii85.PostScript.encode('easy').toString()).to.equal('<~ARTY*~>');
});
});

@@ -9,6 +9,6 @@ 'use strict';

for (i = 10; i < 100; i += 3) {
for (i = 10; i < 100; i += 1) {
it('tests random binarys with length ' + i, function() {
random(10, i).forEach(function(s) {
expect(ascii85.decode(ascii85.encode(s))).to.equal(s);
expect(ascii85.decode(ascii85.encode(s)).toString('binary')).to.equal(s.toString('binary'));
});

@@ -30,3 +30,3 @@ });

strs.push(s);
strs.push(Buffer.from? Buffer.from(s, 'binary'): new Buffer(s, 'binary'));
}

@@ -33,0 +33,0 @@