{"id":31376517,"url":"https://github.com/substrate-system/simple-aes","last_synced_at":"2025-09-28T03:53:48.316Z","repository":{"id":220600415,"uuid":"750059868","full_name":"substrate-system/simple-aes","owner":"substrate-system","description":"The simplest way to use AES keys in the browser or Node.","archived":false,"fork":false,"pushed_at":"2025-09-05T01:07:47.000Z","size":121,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-16T20:40:36.003Z","etag":null,"topics":["aes","aes-encryption","browser","cryptography"],"latest_commit_sha":null,"homepage":"https://substrate-system.github.io/simple-aes/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/substrate-system.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2024-01-29T22:50:51.000Z","updated_at":"2025-09-03T04:17:09.000Z","dependencies_parsed_at":"2024-02-09T09:24:41.610Z","dependency_job_id":"9043d060-9502-4917-a881-1dd57c93f115","html_url":"https://github.com/substrate-system/simple-aes","commit_stats":null,"previous_names":["nichoth/ephemeral-crypto","bicycle-codes/simple-aes","bicycle-codes/ephemeral-crypto","substrate-system/simple-aes"],"tags_count":30,"template":false,"template_full_name":"nichoth/template-ts-browser","purl":"pkg:github/substrate-system/simple-aes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fsimple-aes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fsimple-aes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fsimple-aes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fsimple-aes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/substrate-system","download_url":"https://codeload.github.com/substrate-system/simple-aes/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fsimple-aes/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277322052,"owners_count":25798726,"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","status":"online","status_checked_at":"2025-09-28T02:00:08.834Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["aes","aes-encryption","browser","cryptography"],"created_at":"2025-09-28T03:53:47.298Z","updated_at":"2025-09-28T03:53:48.309Z","avatar_url":"https://github.com/substrate-system.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple AES\n[![tests](https://img.shields.io/github/actions/workflow/status/substrate-system/simple-aes/nodejs.yml?style=flat-square)](https://github.com/substrate-system/simple-aes/actions/workflows/nodejs.yml)\n[![module](https://img.shields.io/badge/module-ESM%2FCJS-blue?style=flat-square)](README.md)\n[![types](https://img.shields.io/npm/types/@substrate-system/simple-aes?style=flat-square)](README.md)\n[![semantic versioning](https://img.shields.io/badge/semver-2.0.0-blue?logo=semver\u0026style=flat-square)](https://semver.org/)\n[![install size](https://flat.badgen.net/packagephobia/install/@substrate-system/simple-aes?cache-control=no-cache)](https://packagephobia.com/result?p=@substrate-system/simple-aes)\n[![GZip size](https://flat.badgen.net/bundlephobia/minzip/@substrate-system/simple-aes)](https://bundlephobia.com/package/@substrate-system/simple-aes)\n[![license](https://img.shields.io/badge/license-Big_Time-blue?style=flat-square)](LICENSE)\n\n\nCryptography used by [vanishing.page](https://vanishing.page/). Works in\nbrowsers and node.\n\nThis is generally useful as a dead simple way of working with symmetric keys\nin a browser or node.\n\nThanks to [Fission](https://github.com/fission-codes/), the original author\nfor much of this code.\n\n\u003c!-- toc --\u003e\n\n- [Install](#install)\n- [Use](#use)\n  * [Bundler](#bundler)\n  * [pre-bundled](#pre-bundled)\n- [API](#api)\n  * [`@substrate-system/simple-aes`](#substrate-systemsimple-aes)\n  * [`@substrate-system/simple-aes/compat`](#substrate-systemsimple-aescompat)\n  * [`encryptMessage`](#encryptmessage)\n  * [`decryptMessage`](#decryptmessage)\n\n\u003c!-- tocstop --\u003e\n\n## Install\n\n```sh\nnpm i -S @substrate-system/simple-aes\n```\n\n## Use\n\n### Bundler\nJust import\n\n```js\nimport {\n    decryptMessage,\n    encryptMessage,\n    type Message\n} from '@substrate-system/simple-aes'\n// } from '@substtrate-system/simple-aes/compat'  // for older browsers\n```\n\n### pre-bundled\nThis exposes pre-bundled \u0026 minified JS files.\n\n#### copy\n\n```sh\ncp ./node_modules/@substrate-system/simple-aes/dist/compat.min.js ./public\ncp ./node_modules/@substrate-system/simple-aes/dist/index.min.js ./public/simple-aes.min.js\n```\n\n#### link\n\n```html\n\u003cbody\u003e\n    \u003c!-- ... --\u003e\n\n    \u003cscript type=\"module\" src=\"./compat.min.js\"\u003e\u003c/script\u003e\n    \u003c!-- or webcrypto version --\u003e\n    \u003cscript type=\"module\" src=\"./simple-aes.min.js\"\u003e\u003c/script\u003e\n\u003c/body\u003e\n```\n\n## API\n\n### `@substrate-system/simple-aes`\n\nUse the `webcrypto` API.\n\n```js\nimport {\n    decryptMessage,\n    encryptMessage,\n    type Message\n} from '@substrate-system/simple-aes'\n```\n\n### `@substrate-system/simple-aes/compat`\n\nUse a user-land module,\n[@noble/ciphers](https://github.com/paulmillr/noble-ciphers). This will work\nin browsers of all ages.\n\n```js\nimport {\n    encryptMessage,\n    decryptMessage\n} from '@substrate-system/simple-aes/compat'\n```\n\n### `encryptMessage`\nGenerate a new AES key and encrypt the given message object.\nReturn an array of `[ encryptedMessage, { key }]`,\nwhere `key` is a new AES key, encoded as `base64url`.\n\nCan pass in a size for the key. By default it uses 256 bits.\n\n```ts\nasync function encryptMessage (\n    msg:{ content:string },\n    opts:{ length:SymmKeyLength } = { length: DEFAULT_SYMM_LEN }\n):Promise\u003c[{ content:string }, { key:string }]\u003e\n```\n\n#### encrypt example\n```ts\nimport { SymmKeyLength, encryptMessage } from '@substrate-system/simple-aes'\n\nconst [encryptedMsg, { key }] = await encryptMessage({\n    content: 'hello world'\n})\n\n// or pass in a key size\nawait encryptMessage({\n    content: 'hello'\n}, {\n    length: SymmKeyLength.B128\n})\n\nconsole.log(encryptedMessage)\n// =\u003e  { content: '5eAcA6+jnBfbuCx8L...' }\n```\n\n### `decryptMessage`\nDecrypt the given message with the given key. Suitable for decrypting a message that was encrypted by this library. Key is an AES key, `base64url` encoded.\n\n```ts\nasync function decryptMessage (\n    msg:{ content:string },\n    keyString:string  // \u003c-- base64url\n):Promise\u003c{ content:string }\u003e\n```\n\n#### decrypt example\n```js\nimport { test } from '@substrate-system/tapzero'\nimport { decryptMessage } from '@substrate-system/simple-aes'\n\ntest('decrypt the message', async t =\u003e {\n    const decrypted = await decryptMessage(message, key)\n    t.equal(decrypted.content, 'hello world',\n        'should decrypt to the right text')\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubstrate-system%2Fsimple-aes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubstrate-system%2Fsimple-aes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubstrate-system%2Fsimple-aes/lists"}