{"id":20392520,"url":"https://github.com/equim-chan/base91","last_synced_at":"2025-04-12T11:54:02.007Z","repository":{"id":65424617,"uuid":"92421356","full_name":"Equim-chan/base91","owner":"Equim-chan","description":":abcd: basE91 codec in pure JavaScript implementation.","archived":false,"fork":false,"pushed_at":"2017-09-02T12:06:56.000Z","size":40,"stargazers_count":14,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-04T20:47:11.474Z","etag":null,"topics":["base91","binary-to-text","decoding","encoding"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Equim-chan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-25T16:12:23.000Z","updated_at":"2024-09-13T23:05:43.000Z","dependencies_parsed_at":"2023-01-23T10:55:21.561Z","dependency_job_id":null,"html_url":"https://github.com/Equim-chan/base91","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Equim-chan%2Fbase91","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Equim-chan%2Fbase91/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Equim-chan%2Fbase91/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Equim-chan%2Fbase91/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Equim-chan","download_url":"https://codeload.github.com/Equim-chan/base91/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248565045,"owners_count":21125414,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base91","binary-to-text","decoding","encoding"],"created_at":"2024-11-15T03:44:14.330Z","updated_at":"2025-04-12T11:54:01.978Z","avatar_url":"https://github.com/Equim-chan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# base91\n[![npm version](https://img.shields.io/npm/v/node-base91.svg?style=flat)](https://www.npmjs.com/package/node-base91)\n[![Build Status](https://img.shields.io/travis/Equim-chan/base91.svg?style=flat)](https://travis-ci.org/Equim-chan/base91)\n[![Coverage Status](https://img.shields.io/coveralls/Equim-chan/base91.svg?style=flat)](https://coveralls.io/github/Equim-chan/base91?branch=master)\n[![Codacy Badge](https://img.shields.io/codacy/grade/9f4a3b6990134a7b9c5fe099dfb41bcd.svg?style=flat)](https://www.codacy.com/app/Equim-chan/base91)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com)\n[![license](https://img.shields.io/npm/l/node-base91.svg?style=flat)](https://github.com/Equim-chan/base91/blob/master/LICENSE)\n\nbasE91 codec implemented in pure JavaScript.\n\nMigrated from the C and PHP version of Joachim Henke's [basE91](http://base91.sourceforge.net/).\n\n[Golang version](https://github.com/Equim-chan/base91-go)\n\n## Installation\n```bash\n$ npm i --save node-base91\n# Or\n$ yarn add node-base91\n```\n\n## Usage\n### Encoding\n```js\nconst base91 = require('node-base91');\nconst fs = require('fs');\n\n// accept string with utf8 encoding by default\nconst encodedText = base91.encode('Hello World!');\nconsole.log(encodedText);  //=\u003e \u003eOwJh\u003eIo0Tv!8PE\n\n// accept string with specified encoding\nconst encodedUnicodeText = base91.encode('Hello World!', 'ucs2');\nconsole.log(encodedUnicodeText);  //=\u003e .AoE~l*hy(bAgA;DDn6yF\"NAyA\u0026AA\n\n// accept Buffer\nconst encodedFile = base91.encode(fs.readFileSync('../../sayaka.jpg'));\n\n// convert hex into base91\nconst encodedHash = base91.encode('ecfbfc2754db0c408223fa7917116867420ef60d', 'hex');\nconsole.log(encodedHash);  //=\u003e y\u003e)~Q7e.XL{xWWXI#WJ2CKy\u003eA\n```\n\n### Decoding\n```js\nconst base91 = require('node-base91');\n\n// with `encoding`, `decode` will return a string\nconst decodedText = base91.decode('\u003eOwJh\u003eIo0Tv!8PE', 'utf8');\nconsole.log(decodedText);  //=\u003e Hello World!\n\n// without `encoding`, `decode` will return a buffer\nconst decodedBuffer = base91.decode('\u003eOwJh\u003eIo0Tv!8PE');\nconsole.log(decodedBuffer);  //=\u003e \u003cBuffer 48 65 6c 6c 6f 20 57 6f 72 6c 64 21\u003e\n\n// convert base91 into hex\nconst decodedHash = base91.decode('y\u003e)~Q7e.XL{xWWXI#WJ2CKy\u003eA', 'hex');\nconsole.log(decodedHash);  //=\u003e ecfbfc2754db0c408223fa7917116867420ef60d\n```\n\n### Stream\n```js\nconst base91 = require('node-base91');\nconst fs = require('fs');\n\n// encoding\nfs\n  .createReadStream('package.json')\n  .pipe(new base91.EncodeStream())\n  .pipe(fs.createWriteStream('package.json.base91'))\n  .on('close', () =\u003e {\n    console.log(fs.readFileSync('package.json.base91', 'utf8'));\n    //=\u003e sd:CAYEIW$iwyCAMlref_f,Hb%\u0026@8YvPM\"^Xxp)z7gg .......\n\n    // decoding\n    fs\n      .createReadStream('package.json.base91')\n      .pipe(new base91.DecodeStream())\n      .pipe(fs.createWriteStream('package.json.decoded'))\n      .on('close', () =\u003e {\n        const origin = fs.readFileSync('package.json');\n        const deEncoded = fs.readFileSync('package.json.decoded');\n        console.log(Buffer.compare(origin, deEncoded) === 0); //=\u003e true\n      });\n  });\n```\n\n## API\n### encode(data[, encoding = 'utf8'])\n* data (`String` | `Buffer`) - Data to be encoded, can be either `String` or `Buffer`.\n* encoding (`String`) - The encoding of `data` string. Default: `'utf8'`. This argument is ignored when `data` is already a `Buffer`.\n* returns (`String`) - basE91 encoded string.\n\n### decode(data[, encoding])\n* data (`String`) - basE91 string to be decoded.\n* encoding (`String`) - The string encoding of decoded data. If `encoding` is not specified, it will return a `Buffer`.\n* returns (`String` | `Buffer`) - Decoded buffer or string.\n\n### new EncodeStream([opt])\n* opt (`Object`) - Options are passed to [`new stream.Transform`](https://nodejs.org/dist/latest-v7.x/docs/api/stream.html#stream_new_stream_transform_options)\n* returns (`EncodeStream`) - Stream encoder.\n\n### new DecodeStream([opt])\n* opt (`Object`) - Options are passed to [`new stream.Transform`](https://nodejs.org/dist/latest-v7.x/docs/api/stream.html#stream_new_stream_transform_options)\n* returns (`DecodeStream`) - Stream decoder.\n\n## Test\n```bash\n$ npm test\n# Or\n$ yarn test\n```\n\n## Benchmark\n```bash\n$ npm run benchmark\n# Or\n$ yarn run benchmark\n```\n\nMy result:\n```\n$ node benchmark\n[control group] dataGen 1KB x 48,643 ops/sec ±1.91% (84 runs sampled)\nbasE91 encoding 1KB x 11,941 ops/sec ±1.71% (85 runs sampled)\nbasE91 decoding 1KB x 3,238 ops/sec ±1.73% (89 runs sampled)\n[control group] dataGen 512KB x 112 ops/sec ±1.54% (79 runs sampled)\nbasE91 encoding 512KB x 12.06 ops/sec ±2.12% (34 runs sampled)\nbasE91 decoding 512KB x 4.91 ops/sec ±4.12% (17 runs sampled)\n[control group] dataGen 1MB x 55.31 ops/sec ±1.98% (69 runs sampled)\nbasE91 encoding 1MB x 5.19 ops/sec ±4.21% (17 runs sampled)\nbasE91 decoding 1MB x 2.19 ops/sec ±6.36% (10 runs sampled)\n[control group] dataGen 4MB x 12.78 ops/sec ±6.12% (35 runs sampled)\nbasE91 encoding 4MB x 1.05 ops/sec ±10.33% (7 runs sampled)\nbasE91 decoding 4MB x 0.43 ops/sec ±9.71% (6 runs sampled)\n=============================================\nTested with Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz x4 under win32 x64 10.0.15063\nAvg basE91 encode speed: 8,327.687 KB/s\nAvg basE91 decode speed: 3,887.838 KB/s\n```\n\n## License\n[BSD-3-clause](https://github.com/Equim-chan/base91/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fequim-chan%2Fbase91","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fequim-chan%2Fbase91","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fequim-chan%2Fbase91/lists"}