{"id":16974682,"url":"https://github.com/alttiri/base85","last_synced_at":"2025-07-25T01:14:17.694Z","repository":{"id":38476346,"uuid":"505081066","full_name":"AlttiRi/base85","owner":"AlttiRi","description":"Pretty fast base85 JavaScript library","archived":false,"fork":false,"pushed_at":"2024-09-06T21:15:34.000Z","size":128,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T12:02:21.767Z","etag":null,"topics":["ascii85","base64","base85","z85"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/@alttiri/base85","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlttiRi.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-19T10:45:59.000Z","updated_at":"2024-09-25T05:51:56.000Z","dependencies_parsed_at":"2024-10-28T13:22:27.111Z","dependency_job_id":"bd257260-ac65-49d8-a761-4905544e8edb","html_url":"https://github.com/AlttiRi/base85","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlttiRi%2Fbase85","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlttiRi%2Fbase85/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlttiRi%2Fbase85/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlttiRi%2Fbase85/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlttiRi","download_url":"https://codeload.github.com/AlttiRi/base85/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244972067,"owners_count":20540917,"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":["ascii85","base64","base85","z85"],"created_at":"2024-10-14T01:07:33.424Z","updated_at":"2025-07-25T01:14:17.681Z","avatar_url":"https://github.com/AlttiRi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [base85](https://github.com/AlttiRi/base85)\n[Pretty fast](https://github.com/AlttiRi/base85/blob/7a6edf4b9c0b16e0d63e35c0c102c1875f78ddb0/tests/test-2-speed.js#L23-L52) base85 JavaScript library (with TS support).\n\nIt is designed to encode binary data (`Uint8Array`) into a \"base85\" text string and vice versa.\n\n```bash\nnpm install @alttiri/base85\n```\n\n## API\n\n#### `function encode(ui8a: Uint8Array, charset?: \"ascii85\" | \"z85\" | string): string`\n\n[`encode`](https://github.com/AlttiRi/base85/blob/45b6cf40a85c475855f739cecd98845b4ede2b1e/base85.ts#L48) encodes the input `Uint8Array` into base85 `string`.\n\n#### `function decode(base85: string, charset?: \"ascii85\" | \"z85\" | string): Uint8Array`\n\n[`decode`](https://github.com/AlttiRi/base85/blob/45b6cf40a85c475855f739cecd98845b4ede2b1e/base85.ts#L90) decodes the input base85 `string` into `Uint8Array`.\n\n`charset` is \"z85\" by default.\n\nAlso, there are `encodeBase85` and `decodeBase85` aliases for `encode` and `decode` functions.\n\n## Examples\n\n\nBinary data encoding example:\n```js\nimport {encodeBase85} from \"@alttiri/base85\";\n\n// png image, 169 bytes\nconst imageBytes = new Uint8Array([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,32,0,0,0,32,8,2,0,0,0,252,24,237,163,0,0,0,1,115,82,71,66,0,174,206,28,233,0,0,0,4,103,65,77,65,0,0,177,143,11,252,97,5,0,0,0,9,112,72,89,115,0,0,14,195,0,0,14,195,1,199,111,168,100,0,0,0,62,73,68,65,84,72,75,237,210,49,10,0,48,8,197,80,239,127,105,187,252,161,208,150,32,93,243,86,149,44,86,191,213,33,131,9,3,200,0,50,128,12,160,92,74,63,242,77,55,217,216,100,48,97,0,25,64,6,144,1,208,189,0,183,189,228,126,66,93,37,1,0,0,0,0,73,69,78,68,174,66,96,130]);\nconst base85 = encodeBase85(imageBytes);\n\nconsole.log(base85);\nconsole.log(base85.length);\n// \"Ibl@q4gj0X0000dnK#lE0000w0000w2M:#a0q)Y3Qw$n]0DRdeliagl9o^C600D}2o*F:VV5Yp\u003cvfDSh010Qns-TMy4-nnD4-ns/z(vgD002hOl{T^yoypdZ3ih:=-zD2Mx$Kqp^3t!W]h.bcr\u003e)fdG9.U305x6kPJ\u003e8N[\u003ez6@/KMWA02X3aKo9.w0jPV5ENmr^0rr9107/QOm6n\u003c:F=\"\n// 212\n```\n\n---\n\nIf you need to encode a text _(are you really need it?)_ [use `TextEncoder`/`TextDecoder`](https://github.com/AlttiRi/base85/blob/45b6cf40a85c475855f739cecd98845b4ede2b1e/tests/util.js#L17-L29).\n\n```js\nconst input = \"Man is distinguished\";\nconst inputBytes = utf8StringToArrayBuffer(input);\nconsole.log(encode(inputBytes, \"ascii85\"));  // \"9jqo^BlbD-BleB1DJ+*+F(f,q\"\nconsole.log(encode(inputBytes, \"z85\"));      // \"o\u003c}]Zx(+zcx(!xgzFa9aB7/b}\"\n\nconst outputBytes = decode(\"9jqo^BlbD-BleB1DJ+*+F(f,q\", \"ascii85\");\nconst output = arrayBufferToUtf8String(outputBytes);\nconsole.log(output); // \"Man is distinguished\"\n```\n\nFor more examples see [the tests](https://github.com/AlttiRi/base85/tree/master/tests).\n\n\n---\n\nYou can test the lib online in the browser's console: https://alttiri.github.io/base85/online\n\nAll required things are already in the global scope. (`encode`, `decode`; util functions: `utf8StringToArrayBuffer` and others.)\n\n---\n\nNote.\nThe optimisation for `\"ascii85\"` by replacing `\"\\0\\0\\0\\0\"` by `\"z\"` instead of `\"!!!!!\"` and `\"    \"` (4 spaces) by `\"y\"` instead of `\"+\u003cVdL\"` is not supported.\n\nAnyway nobody forbids you to do something like `base85.replaceAll(\"!!!!!\", \"z\")` as well as to add `\"\u003c~\"`, `\"~\u003e\"` manually if you need it.\n\n---\n\n# *.d.ts\n\n```ts\n/** 85 unique characters string */\ntype CharSet = string;\n/**\n * Returns Base85 string.\n * @param {Uint8Array} ui8a - input data to encode\n * @param {\"ascii85\" | \"z85\" | string} [charset=\"z85\"] - 85 unique characters string\n * @return {string}\n * */\nexport declare function encode(ui8a: Uint8Array, charset?: \"ascii85\" | \"z85\" | CharSet): string;\n/**\n * Decodes Base85 string.\n * @param {string} base85 - base85 encoded string\n * @param {\"ascii85\" | \"z85\" | string} [charset=\"z85\"] - 85 unique characters string\n * @return {Uint8Array}\n * */\nexport declare function decode(base85: string, charset?: \"ascii85\" | \"z85\" | CharSet): Uint8Array;\n/** Alias to `encode`. */\nexport declare const encodeBase85: typeof encode;\n/** Alias to `decode`. */\nexport declare const decodeBase85: typeof decode;\ndeclare const base85: {\n    encode: typeof encode;\n    decode: typeof decode;\n    encodeBase85: typeof encode;\n    decodeBase85: typeof decode;\n};\nexport default base85;\n```\n\n---\n\n## Installation\n\n### From NPM\n\n```bash\nnpm install @alttiri/base85\n```\n\n### From GitHub repository\n\n```bash\nnpm install git+https://github.com/alttiri/base85.git\n```\n\n\u003cdetails\u003e\n\n\u003csummary\u003eMore ways\u003c/summary\u003e\n\n### From GitHub repository (a specific version):\n\n- **Based on SemVer:**\n    ```bash\n    npm install git+https://github.com/alttiri/base85.git#semver:1.5.1\n    ```\n  Or add\n    ```\n    \"@alttiri/base85\": \"github:alttiri/base85#semver:1.5.1\"\n    ```\n  as `dependencies` in `package.json` file.\n\n  See available [tags](https://github.com/AlttiRi/base85/tags).\n\n- **Based on a commit hash:**\n    ```bash\n    npm install git+https://git@github.com/alttiri/base85.git#ca3217f3d1075b8ff0966e24437326a6c2537bbc\n    ```\n  Or add\n    ```\n    \"@alttiri/base85\": \"github:alttiri/base85#ca3217f3d1075b8ff0966e24437326a6c2537bbc\"\n    ```\n  as `dependencies` in `package.json` file.\n\n  See available [commits hashes](https://github.com/AlttiRi/base85/commits/master).\n\n\n### From GitHub Packages:\nTo install you need first to create `.npmrc` file with `@alttiri:registry=https://npm.pkg.github.com` content:\n```bash\necho @alttiri:registry=https://npm.pkg.github.com \u003e\u003e .npmrc\n```\n\nonly then run\n\n```bash\nnpm install @alttiri/base85\n```\nNote, that GitHub Packages requires to have also `~/.npmrc` file (`.npmrc` in your home dir) with `//npm.pkg.github.com/:_authToken=TOKEN` content, where `TOKEN` is a token with the `read:packages` permission, take it here https://github.com/settings/tokens/new.\n\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falttiri%2Fbase85","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falttiri%2Fbase85","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falttiri%2Fbase85/lists"}