{"_id":"@caratlanedg/cl-crypto","_rev":"2-516624fb71b554cb03454e7eaca4aeba","name":"@caratlanedg/cl-crypto","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.0":{"name":"@caratlanedg/cl-crypto","version":"1.0.0","keywords":["npm","math"],"author":{"name":"Sureshkumar"},"license":"MIT","_id":"@caratlanedg/cl-crypto@1.0.0","maintainers":[{"name":"caratlanedg","email":"cldigigld@caratlane.com"}],"dist":{"shasum":"bede4b78b17fe3b9100be85b6c9cfc07756782da","tarball":"https://registry.npmjs.org/@caratlanedg/cl-crypto/-/cl-crypto-1.0.0.tgz","fileCount":4,"integrity":"sha512-eofI69g5n2S12BBPhrK9/ss2bRIb7jGLrS5kjvevKxPSkMWMuG21n0n+QCYvp7rP7M1z6M8PbLByxDG46PCx/A==","signatures":[{"sig":"MEUCIFwIIT2ZelRrQeE/ITu6bXq+uJvGEtZn0HYSG5QEKRUDAiEA+kZMlqwhIjXheIjWwDBP1MSVxTY7G4onmTgrA0volPE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":6659},"main":"./src/index.js","type":"module","engines":{"node":">=18"},"exports":{".":"./src/index.js"},"scripts":{"validate":"node scripts/validate.js"},"// ABOUT":"cl-crypto — AES-128/192/256 in ECB mode with PKCS5 padding; matches Java Cipher.getInstance(\"AES/ECB/PKCS5Padding\") and SecretKeySpec(key.getBytes(UTF_8), \"AES\").","// ENTRY":"ESM: import from \"cl-crypto\" → ./src/index.js (encrypt, decrypt). Node 18+.","_npmUser":{"name":"caratlanedg","email":"cldigigld@caratlane.com"},"// SCRIPTS":"npm run validate — runs scripts/validate.js (round-trip smoke check).","_npmVersion":"11.12.0","description":"AES-128/192/256 ECB with PKCS5 padding: encrypt/decrypt AES/ECB/PKCS5Padding and UTF-8 SecretKeySpec.","directories":{},"sideEffects":false,"_nodeVersion":"24.14.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/cl-crypto_1.0.0_1778482306962_0.8616852114487159","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"// ABOUT":"cl-crypto — AES-128/192/256 in ECB mode with PKCS5 padding; matches Java Cipher.getInstance(\"AES/ECB/PKCS5Padding\") and SecretKeySpec(key.getBytes(UTF_8), \"AES\").","// ENTRY":"ESM: import \"cl-crypto\" → ./src/index.js. CJS: require(\"cl-crypto\") → ./cjs/index.cjs. Node 18+.","// SCRIPTS":"npm run build:cjs — emits cjs/index.cjs from src/index.js. npm run validate — build + ESM/CJS smoke checks.","name":"@caratlanedg/cl-crypto","version":"1.1.0","description":"AES-128/192/256 ECB with PKCS5 padding: encrypt/decrypt AES/ECB/PKCS5Padding and UTF-8 SecretKeySpec.","type":"module","main":"./cjs/index.cjs","exports":{".":{"import":"./src/index.js","require":"./cjs/index.cjs"}},"sideEffects":false,"engines":{"node":">=18"},"scripts":{"build:cjs":"esbuild src/index.js --platform=node --target=node18 --format=cjs --outfile=cjs/index.cjs --legal-comments=none","prepublishOnly":"npm run build:cjs","validate":"npm run build:cjs && node scripts/validate.js && node scripts/validate-cjs.cjs"},"keywords":["npm","math"],"author":{"name":"Sureshkumar"},"license":"MIT","devDependencies":{"esbuild":"^0.28.0"},"_id":"@caratlanedg/cl-crypto@1.1.0","_nodeVersion":"16.16.0","_npmVersion":"8.11.0","dist":{"integrity":"sha512-HCpHuTtty5I/xEtXKG1poGqKeDUJT1upNZSK3h+ve9y+PJOzvRZOAWBIGG4wviOR0nnei6YeuoqM/qVTvPKlsQ==","shasum":"0e8f4eb22dacc9d791b14b10a901a5f2b97058b9","tarball":"https://registry.npmjs.org/@caratlanedg/cl-crypto/-/cl-crypto-1.1.0.tgz","fileCount":5,"unpackedSize":9333,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEMCIBLZ9zGL5lLhbYeLt6sTcYl3wTNXJpGQ/XqDdL0FRNvsAh8ea19Ho/iYcK3DJrC1G8kOYqqh01AbOaqfEdnCIc21"}]},"_npmUser":{"name":"caratlanedg","email":"cldigigld@caratlane.com"},"directories":{},"maintainers":[{"name":"caratlanedg","email":"cldigigld@caratlane.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/cl-crypto_1.1.0_1778596037702_0.9910138943181717"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-11T06:51:46.759Z","modified":"2026-05-12T14:27:17.979Z","1.0.0":"2026-05-11T06:51:47.112Z","1.1.0":"2026-05-12T14:27:17.868Z"},"author":{"name":"Sureshkumar"},"license":"MIT","keywords":["npm","math"],"description":"AES-128/192/256 ECB with PKCS5 padding: encrypt/decrypt AES/ECB/PKCS5Padding and UTF-8 SecretKeySpec.","maintainers":[{"name":"caratlanedg","email":"cldigigld@caratlane.com"}],"readme":"# cl-crypto\n\nAES-128, AES-192, and AES-256 **ECB** with **PKCS5** padding for Node.js, matching Java [`Cipher#getInstance`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/javax/crypto/Cipher.html#getInstance(java.lang.String))(`\"AES/ECB/PKCS5Padding\"`) where the key comes from **`SecretKeySpec(keyString.getBytes(UTF_8), \"AES\")`**.\n\nRequires **Node.js 18+** (ES modules and [`node:crypto`](https://nodejs.org/api/crypto.html)).\n\n## Install\n\nPublished package:\n\n```bash\nnpm install cl-crypto\n```\n\nLocal path dependency:\n\n```json\n{\n  \"dependencies\": {\n    \"cl-crypto\": \"file:../cl-crypto\"\n  }\n}\n```\n\nThen:\n\n```bash\nnpm install\n```\n\nThe package exposes **ESM** and **CommonJS** via [`exports`](https://nodejs.org/api/packages.html#conditional-exports): `import` resolves to ESM, `require` to CJS.\n\n## Usage\n\n**ESM**\n\n```javascript\nimport { encrypt, decrypt } from 'cl-crypto';\n\nconst key = '1234567890123456'; // 16 UTF‑8 bytes → AES-128\nconst ciphertext = encrypt('plain text', key);\nconst plaintext = decrypt(ciphertext, key);\n```\n\n**CommonJS**\n\n```javascript\nconst { encrypt, decrypt } = require('cl-crypto');\n\nconst key = '1234567890123456';\nconst ciphertext = encrypt('plain text', key);\nconst plaintext = decrypt(ciphertext, key);\n```\n\n## API\n\n### `encrypt(value, key)`\n\n- **`value`** — plaintext string (UTF‑8 bytes are encrypted).\n- **`key`** — secret string interpreted as UTF‑8; length must be **16**, **24**, or **32** bytes (AES‑128, AES‑192, AES‑256).\n- **Returns** — Base64 ciphertext.\n\n### `decrypt(value, key)`\n\n- **`value`** — Base64 string produced by `encrypt`.\n- **`key`** — same `key` as for encryption.\n- **Returns** — plaintext string (UTF‑8 decoded).\n\nWrong key lengths throw: `AES key must be 16, 24, or 32 bytes when UTF-8 encoded; got …`\n\n## Java interoperability\n\nEncrypt (conceptually the same pipeline as this package):\n\n```java\nCipher cipher = Cipher.getInstance(\"AES/ECB/PKCS5Padding\");\ncipher.init(Cipher.ENCRYPT_MODE,\n    new SecretKeySpec(keyString.getBytes(StandardCharsets.UTF_8), \"AES\"));\nbyte[] ciphertext = cipher.doFinal(plaintextString.getBytes(StandardCharsets.UTF_8));\nString base64 = Base64.getEncoder().encodeToString(ciphertext);\n```\n\nDecrypt:\n\n```java\nCipher cipher = Cipher.getInstance(\"AES/ECB/PKCS5Padding\");\ncipher.init(Cipher.DECRYPT_MODE,\n    new SecretKeySpec(keyString.getBytes(StandardCharsets.UTF_8), \"AES\"));\nbyte[] plain = cipher.doFinal(Base64.getDecoder().decode(base64Ciphertext));\nString plaintext = new String(plain, StandardCharsets.UTF_8);\n```\n\nUse the **same** key string and UTF‑8 encoding on both sides.\n\n## Development\n\nFrom the package root:\n\n```bash\nnpm run validate\n```\n\nRebuilds `cjs/index.cjs` from `src/index.js` (esbuild), then runs ESM and CJS smoke checks (`scripts/validate.js` and `scripts/validate-cjs.cjs`). After editing `src/index.js`, commit the regenerated `cjs/index.cjs` or run `npm run build:cjs` before publish.\n\n## Security\n\nECB does not use an IV; repeated plaintext blocks produce repeated ciphertext. Prefer **AES‑GCM** (or similar) for new systems. This package is for compatibility with existing ECB‑based integrations.\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md"}