{"id":14984995,"url":"https://github.com/carlrosell/simple_aes_cbc","last_synced_at":"2025-04-10T23:14:53.683Z","repository":{"id":198686921,"uuid":"701299537","full_name":"carlrosell/simple_aes_cbc","owner":"carlrosell","description":"A simple wrapper for WebCrypto which uses the AES-CBC algorithm","archived":false,"fork":false,"pushed_at":"2023-12-13T09:48:40.000Z","size":14,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T23:14:45.439Z","etag":null,"topics":["decryption","deno","encryption","javascript","typescript"],"latest_commit_sha":null,"homepage":"https://deno.land/x/simple_aes_cbc","language":"TypeScript","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/carlrosell.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":"2023-10-06T10:56:30.000Z","updated_at":"2024-11-18T10:44:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"5a4663bc-39af-4e39-9168-5603d74887c8","html_url":"https://github.com/carlrosell/simple_aes_cbc","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"6c32ff82d96aed7444dcf44735b01c8d11ff54d6"},"previous_names":["carlrosell/simple_aes_cbc"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlrosell%2Fsimple_aes_cbc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlrosell%2Fsimple_aes_cbc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlrosell%2Fsimple_aes_cbc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carlrosell%2Fsimple_aes_cbc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carlrosell","download_url":"https://codeload.github.com/carlrosell/simple_aes_cbc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248312134,"owners_count":21082638,"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":["decryption","deno","encryption","javascript","typescript"],"created_at":"2024-09-24T14:10:04.057Z","updated_at":"2025-04-10T23:14:53.659Z","avatar_url":"https://github.com/carlrosell.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# simple_aes_cbc\n\nThis is a TypeScript module that provides a simple class for encryption and\ndecryption functionality. It uses the `AES-CBC`-algorithm and it uses `atob` and\n`btoa` functions to perform base64 encoding/decoding.\n\n## Installation\n\n### deno\n\n```typescript\nimport { SimpleAesCbc } from \"https://deno.land/x/simple_aes_cbc/mod.ts\";\n```\n\n### node\n\n```\nnpm install simple-aes-cbc\nbun install simple-aes-cbc\nyarn install simple-aes-cbc\n\n... etc\n```\n\n## Usage\n\nHere's an example of how to use this module:\n\n### deno\n\n```typescript\nimport { SimpleAesCbc } from \"https://deno.land/x/simple_aes_cbc/mod.ts\";\n\nconst stringCrypto = new SimpleAesCbc(\"1234567890123456\", crypto.subtle);\n\nconst data = \"hello my friend\";\n\nconst encrypted = await stringCrypto.encryptString(data);\n\nconst decrypted = await stringCrypto.decryptString(encrypted);\n\nconsole.log(decrypted); // \"hello my friend\"\n```\n\n### node\n\n```typescript\nimport { webcrypto } from \"node:crypto\";\nimport { SimpleAesCbc } from \"simple-aes-cbc\";\n\nconst stringCrypto = new SimpleAesCbc(\"1234567890123456\", webcrypto.subtle);\n\n// ... same as above\n```\n\n## API\n\n### `new SimpleAesCbc(private_key: Uint8Array | string, subtle: SubtleCrypto, iv?: Uint8Array | string)`\n\nThis is the constructor of the `SimpleAesCbc` class. It takes three arguments:\n\n- `private_key`, 16, 24 or 32 bytes\n- [`subtle`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto).\n  Which is used to encrypt and decrypt the data\n- optional `iv`, 16 bytes.\n\n#### `encrypt(data: BufferSource): Promise\u003cArrayBuffer\u003e`\n\nThis method encrypts the given data.\n\n#### `decrypt(data: BufferSource): Promise\u003cArrayBuffer\u003e`\n\nThis method decrypts the given data.\n\n#### `encryptString(data: string): Promise\u003cstring\u003e`\n\nEncrypts the given string using the private key. The encrypted string returned\nfrom this function might not be human readable or used safely in a URL. If you\nwant a human readable string that is safe to use, use\n[`encryptStringSafe`](#encryptstringsafe) instead.\n\n#### `decryptString(data: string): Promise\u003cstring\u003e`\n\nDecrypts the given string using the private key. This function expects the\nstring to be in the same format as the one returned from\n[`encryptString`](#encryptstring). If you want to decrypt a string that was\nencrypted using [`encryptStringSafe`](#encryptstringsafe), use\n[`decryptStringSafe`](#decryptstringsafe) instead.\n\n#### `encryptStringToBase64(data: string): Promise\u003cstring\u003e`\n\nEncrypts the given string to a base64 encoded string using the private key. The\nencrypted string returned from this function is human readable and safe to use\nin a URL.\n\n#### `decryptStringFromBase64(data: string): Promise\u003cstring\u003e`\n\nDecrypts the given base64 encoded string using the private key. This function\nexpects the string to be in the same format as the one returned from\n[`encryptStringToBase64`](#encryptstringtobase64).\n\n## License\n\nThis module is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlrosell%2Fsimple_aes_cbc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarlrosell%2Fsimple_aes_cbc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarlrosell%2Fsimple_aes_cbc/lists"}