{"id":20296001,"url":"https://github.com/fdorantesm/cryptaculous","last_synced_at":"2025-06-14T05:07:39.516Z","repository":{"id":246030600,"uuid":"819891338","full_name":"fdorantesm/cryptaculous","owner":"fdorantesm","description":"A utility with zero dependencies to encrypt and decrypt values ​​by abstracting the native crypto package.","archived":false,"fork":false,"pushed_at":"2024-06-30T03:53:34.000Z","size":261,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-12T02:51:56.622Z","etag":null,"topics":["aes-128","aes-192","aes-256","aes-encryption","cbc","crypt","crypto","ctr","decryption","ecf","encryption","node","nodejs"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/cryptaculous","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/fdorantesm.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":"2024-06-25T11:37:33.000Z","updated_at":"2024-07-04T03:46:28.000Z","dependencies_parsed_at":"2024-06-25T13:17:02.231Z","dependency_job_id":"b9c465c6-f98a-4743-a0ef-185393237763","html_url":"https://github.com/fdorantesm/cryptaculous","commit_stats":null,"previous_names":["fdorantesm/cryptaculous"],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/fdorantesm/cryptaculous","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdorantesm%2Fcryptaculous","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdorantesm%2Fcryptaculous/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdorantesm%2Fcryptaculous/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdorantesm%2Fcryptaculous/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fdorantesm","download_url":"https://codeload.github.com/fdorantesm/cryptaculous/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fdorantesm%2Fcryptaculous/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259763102,"owners_count":22907413,"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":["aes-128","aes-192","aes-256","aes-encryption","cbc","crypt","crypto","ctr","decryption","ecf","encryption","node","nodejs"],"created_at":"2024-11-14T15:36:55.766Z","updated_at":"2025-06-14T05:07:39.499Z","avatar_url":"https://github.com/fdorantesm.png","language":"TypeScript","funding_links":["https://paypal.me/fdorantesm"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eCryptaculous\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n\u003cbr\u003e\n\n\u003ci\u003eA crypt utility with zero dependencies to encrypt and decrypt data ​​by abstracting the native crypto module.\u003c/i\u003e\n\n\u003ca href=\"https://github.com/fdorantesm/cryptaculous/stargazers\"\u003e\u003cimg src=\"https://img.shields.io/github/stars/fdorantesm/cryptaculous\" alt=\"Stars Badge\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/fdorantesm/cryptaculous/network/members\"\u003e\u003cimg src=\"https://img.shields.io/github/forks/fdorantesm/cryptaculous\" alt=\"Forks Badge\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/fdorantesm/cryptaculous/pulls\"\u003e\u003cimg src=\"https://img.shields.io/github/issues-pr/fdorantesm/cryptaculous?color=cyan\" alt=\"Pull Requests Badge\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/fdorantesm/cryptaculous/issues\"\u003e\u003cimg src=\"https://img.shields.io/github/issues/fdorantesm/cryptaculous?color=red\" alt=\"Issues Badge\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/fdorantesm/cryptaculous/graphs/contributors\"\u003e\u003cimg alt=\"GitHub contributors\" src=\"https://img.shields.io/github/contributors/fdorantesm/cryptaculous\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/fdorantesm/cryptaculous/blob/master/LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/github/license/fdorantesm/cryptaculous?color=2b9348\" alt=\"License Badge\"/\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n### Supported Algorithms\n\n| Algorithm | Secure |\n|--------------------|--------|\n| AES_128_CBC        | 🟢 Yes |\n| AES_192_CBC        | 🟢 Yes |\n| AES_256_CBC        | 🟢 Yes |\n| AES_128_CFB        | 🟢 Yes |\n| AES_192_CFB        | 🟢 Yes |\n| AES_256_CFB        | 🟢 Yes |\n| AES_128_CTR        | 🟢 Yes |\n| AES_192_CTR        | 🟢 Yes |\n| AES_256_CTR        | 🟢 Yes |\n| AES_128_ECB        | 🔴 No  |\n| AES_192_ECB        | 🔴 No  |\n| AES_256_ECB        | 🔴 No  |\n| AES_128_OFB        | 🟢 Yes |\n| AES_192_OFB        | 🟢 Yes |\n| AES_256_OFB        | 🟢 Yes |\n| CHACHA20_POLY_1305 | 🟢 Yes |\n| RSA                | 🟢 Yes |\n\n### Examples\n\nTry to use secure algorythms but the most important is how you protect the keys.\n\n#### Usage\n\n### Factory method\n\nUsing the factory method\n\n```ts\nimport { EncryptionFactory, Algorithm } from 'cryptaculous';\n\nconst crypt = EncryptionFactory.createEncryption(Algorithm.AES_256_CBC, {\n    key: \"1c5b2bc5789a0f9b0c576950aaf049b6\",\n    iv: \"704a59f3d523c765\",\n});\n\nconst cryptedSecret = crypt.encrypt(\"secret\");        // -\u003e EV2YEWJZcpLdBrkqdDij3Q==\nconst decryptedSecret = crypt.decrypt(cryptedSecret); // -\u003e secret\n```\n\n### Strategy pattern\n\nUsing a strategies to change the strategy in execution time\n\n```ts\nimport { Encryption, Aes256Cbc } from 'cryptaculous';\n\nconst crypt = new Encryption();\n\nif (config.encryptionAlgorith === Algorithm.AES_256_CBC) {\n    crypt.setStrategy(new Aes256Cbc({\n      key: \"1c5b2bc5789a0f9b0c576950aaf049b6\",\n      iv: \"704a59f3d523c765\",\n    }))\n}\n\nconst secret = \"secret\";\nconst crypted = crypt.encrypt(secret);    // -\u003e EV2YEWJZcpLdBrkqdDij3Q==\nconst decrypted = crypt.decrypt(crypted); // -\u003e secret\n```\n\nNote: If no strategy set throws `MissingStrategyException`\n\nRandom encryption is a secure way to use different key and initial vector without defining them each time.\n\nIt allows you to generate encryption by passing only the value to be encrypted, and it will generate the key and the vector, returning them as a keychain for future use.\n\nThe decrypt method receives that keychain and returns the original value.\n\n### RandomEncryption\n\nNote: Only compatible with Symmetric algorythms\n\n```ts\nimport { RandomEncryption, Algorithm } from 'cryptaculous';\n\nconst cryptedValue = RandomEncryption.encrypt(Algorithm.AES_256_CBC, \"secret\");\n\n/*\n  cryptedValue {\n    payload: 'sSnpCXqFnB+Q1VIf4bL0Fw==',\n    algorithm: 'aes-256-cbc',\n    key: '3668f7a00c5b762c14f2792b0fa866e3',\n    iv: '5f5806eca2eceae3'\n  }\n*/\n\nconst decryptedValue = RandomEncryption.decrypt(cryptedValue) // -\u003e secret\n```\n\n### RSA\n\n```ts\nimport { Encryption, RsaEncryption } from 'cryptaculous';\n\nconst encryption = new Encryption();\nconst rsaStrategy = new RsaEncryption();\n\nconst { privateKey, publicKey } = RsaEncryption.generateKeyPairSync('rsa', {\n    modulusLength: 2048,\n    publicKeyEncoding: { type: 'spki', format: 'pem' },\n    privateKeyEncoding: { type: 'pkcs8', format: 'pem' },\n});\n\nencryption.setStrategy(rsaStrategy);\nrsaStrategy.setKeys({ privateKey, publicKey });\n\nconst secret = 'secret';\nconst crypted = encryption.encrypt(secret); \n\n/*\ncryped:\nG8r816lSY0MVBcxq4EY14SeaoU4oIAK9I2PP8bksLt3KpVzkr7Ncnt4g9517noffn9P1dHbdwxvw9EIMjD4JtuR2okL4TK0BjgMlAoN07SikHmucmcoVF9IdFAK7FcT6LiEveVktSN+Wfu/nOQLH3t032Tk2aaS9vOVGo8j6LFSf5zZcJpgs4/mLh7Z25SUden47CFc2X18I+BUx6ufKfGulq3CLO4oyXGQ+Pw0BNLH5ZRr564kaJcrKx4Dr/ZxxdMVEj8N6K39MonVGebTlNCHbkJdFh0z/bklJXRaGeMke6homSD3yKvb7O45LOlz+fKme2MvCWl+8LLt4SB/cUQ==\n*/\n\nconst decrypted = encryption.decrypt(crypted);\n\nconst decryptedValue = RandomEncryption.decrypt(cryptedValue) // -\u003e secret\n\n// You could use compare method\nrsa.compare(\"secret\", crypted) // -\u003e true\n```\n\n### Exceptions\n\n| name                          |\n|:------------------------------|\n| UnsupportedAlgorithmException |\n| MissingStrategyException      |\n| InvalidKeyLengthException     |\n| InvalidIVLengthException      |\n| DecryptionFailedException     |\n| EncryptionFailedException     |\n| MissingPrivateKeyException    |\n| MissingPublicKeyException     |\n\n\u003cbr\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://github.com/fdorantesm\" target=\"_blank\"\u003e\n        \u003cimg src=https://img.shields.io/badge/github-%2324292e.svg?\u0026style=for-the-badge\u0026logo=github\u0026logoColor=white alt=github style=\"margin-bottom: 5px;\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://twitter.com/fdorantesm\" target=\"_blank\"\u003e\n        \u003cimg src=https://img.shields.io/badge/twitter-%2300acee.svg?\u0026style=for-the-badge\u0026logo=twitter\u0026logoColor=white alt=twitter style=\"margin-bottom: 5px;\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://linkedin.com/in/fdorantesm\" target=\"_blank\"\u003e\n        \u003cimg src=https://img.shields.io/badge/linkedin-%231E77B5.svg?\u0026style=for-the-badge\u0026logo=linkedin\u0026logoColor=white alt=linkedin style=\"margin-bottom: 5px;\" /\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.youtube.com/user/FernandoDorantes\" target=\"_blank\"\u003e\n        \u003cimg src=https://img.shields.io/badge/youtube-%23EE4831.svg?\u0026style=for-the-badge\u0026logo=youtube\u0026logoColor=white alt=youtube style=\"margin-bottom: 5px;\" /\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr/\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003ca href=\"https://paypal.me/fdorantesm\" target=\"_blank\" style=\"display: inline-block;\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Donate-PayPal-blue.svg?style=flat-square\u0026logo=paypal\" /\u003e\n    \u003c/a\u003e\n\u003c/div\u003e  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdorantesm%2Fcryptaculous","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffdorantesm%2Fcryptaculous","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffdorantesm%2Fcryptaculous/lists"}