{"name":"kruptein","version":"3.0.9","keywords":["crypto","cryptography","cryptr","crypter","encryption","decryption","encrypt","decrypt","AES","GCM","authenticated","authenticate","unicode","symmetric","cipher","key derivation","scrypt","pbkdf2","security","asn.1"],"author":{"name":"Jason Gerfen","email":"jason.gerfen@gmail.com"},"license":"MIT","_id":"kruptein@3.0.9","maintainers":[{"name":"jas-","email":"jason.gerfen@gmail.com"}],"homepage":"https://github.com/jas-/kruptein#readme","bugs":{"url":"https://github.com/jas-/kruptein/issues"},"dist":{"shasum":"218ccc0e7606c71cadb8659b161813f48e4d0948","tarball":"http://registry-npm.ywwl.com/kruptein/download/kruptein-3.0.9.tgz","fileCount":8,"integrity":"sha512-5Dqevy1xx8ExJ8e5x4WRcT3eDabjq93aZmO+wXrF7HLpAPd8nfo02mY3MmsyMkdTjJkIQP3QSr9MAiciCnAiEA==","signatures":[{"sig":"MEQCICBAGPW4V4Tt5aqXVYdZ1eSppzQlQJ4toXStb2AxZhHYAiBZH5zlrSKVHsz5jPYgPqRelheG0O5cvj0X9bB0pO/MUA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24822,"size":8760,"noattachment":false,"key":"/kruptein/-/kruptein-3.0.9.tgz"},"engines":{"node":">8"},"gitHead":"a983004d0375e33cf658d52544d5932e76236b40","scripts":{"test":"nyc mocha test/*.js"},"_npmUser":{"name":"jas-","email":"jason.gerfen@gmail.com"},"repository":{"url":"git+https://github.com/jas-/kruptein.git","type":"git"},"_npmVersion":"10.5.0","description":"crypto; from kruptein to hide or conceal","directories":{},"_nodeVersion":"20.12.1","dependencies":{"asn1.js":"^5.4.1"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"17.1.0","mocha":"^11.0.0","expect.js":"0.3.1"},"_npmOperationalInternal":{"tmp":"tmp/kruptein_3.0.9_1763464013054_0.8284665034471383","host":"s3://npm-registry-packages-npm-production"},"readme":"\n🔐 kruptein \n========\ncrypto (krip-toh); from `kruptein` to hide or conceal.\n\n[![npm](https://img.shields.io/npm/v/kruptein.svg)](https://npmjs.com/package/kruptein)\n![Downloads](https://img.shields.io/npm/dm/kruptein.svg)\n[![Known Vulnerabilities](https://snyk.io/test/github/jas-/kruptein/badge.svg)](https://snyk.io/test/github/jas-/kruptein)\n![Build Status](https://github.com/jas-/kruptein/actions/workflows/node.js.yml/badge.svg)\n\n\n🔬 Sandbox\n-------\n Here you can experiment with the module to ensure it will suit your needs. [kruptein @ codesandbox.io](https://codesandbox.io/p/devbox/romantic-wu-cywk2c)\n\n\n🔒 Encrypt\n-----------------\nEncrypt a plaintext message using the default options.\n\n```javascript\nconst kruptein = require(\"kruptein\")();\nconst secret = \"S3cre+_Squ1rr3l\";\nconst plaintext = \"Some kind of wonderfully private message\";\n\nkruptein.set(secret, plaintext, (error, ciphertext) => {\n  if (error) {\n    throw new Error(error);\n  }\n\n  console.log(ciphertext);\n});\n```\n\n\n🔓 Decrypt\n------------------\nDecrypt a ciphertext returned by `kruptein.set()` using the same secret.\n\n```javascript\nconst kruptein = require(\"kruptein\")();\nconst secret = \"S3cre+_Squ1rr3l\";\nconst ciphertext = \"<ciphertext returned by kruptein.set()>\";\n\nkruptein.get(secret, ciphertext, (error, plaintext) => {\n  if (error) {\n    throw new Error(error);\n  }\n\n  console.log(plaintext);\n});\n```\n\n\n📦 Install\n-------\nTo install `npm install kruptein`\n\n\n👓 Methods\n-------\n*   `.set(secret, plaintext, [aad], callback)`\n*   `.get(secret, ciphertext, [{at: auth_tag, aad: aad}], callback)`\n\n\n🛠️ Options\n-------\nIndustry standards are used for the algorithm, hashing algorithm, key & IV sizes.\nThe default key derivation function is `pbkdf2`, however use of the `scrypt` or `argon2` can be used as well.\n\n#### Cryptography options\n*   `algorithm`: (Optional) Cipher algorithm from `crypto.getCiphers()`. Default: `aes-256-gcm`.\n*   `hashing`: (Optional) Hash algorithm from `crypto.getHashes()`. Default: `sha384`.\n*   `key_size`: (Optional) Key size bytes (should match block size of algorithm). Default: `32`\n*   `iv_size`: (Optional) IV size bytes. Default: `16`.\n*   `at_size`: (Optional) Authentication tag size. Applicable to `gcm` & `ocb` cipher modes. Default: `128`.\n\n#### Key derivation options\n*   `use_scrypt`: (Optional) Use `.scrypt()` to derive a key. Requires node > v10. Default/Fallback: `.pbkdf2()`.\n*   `use_argon2`: (Optional) Use `.argon2id()` to derive a key. Requires node > v24. Default/Fallback: `.pbkdf2()`.\n\n#### Encoding options\n*   `encodeas`: (Optional) Output encoding. Currently supports `binary`, `hex`, & `base64`. Default: `base64`.\n*   `use_asn1`: (Optional) Disable the default ASN.1 encoding. Default: true\n\n\n📐 Options example\n-----------------\nAn example of creating a new ciphertext object.\n\n```javascript\nconst opts = {\n  algorithm: 'aes-256-gcm',\n  hashing: 'sha384',\n  key_size: 64,\n  iv_size: 16,\n  at_size: 128,\n  use_argon2: true,\n  encodeas: 'base64',\n  use_asn1: true\n}\n\nconst kruptein = require(\"kruptein\")(opts || {});\n```\n\n\n🗝️ Usage\n-----\nWhen selecting an algorithm from `crypto.getCiphers()` the `iv` and `key_size` values are calculated auto-magically to make implementation easy.\n\nYou can always define your own if the defaults per algorithm and mode aren't what you would like; see the `options` section above.\n\nThe `secret` must meet [complexity requirements](https://github.com/jas-/kruptein/blob/5d41a5fa35101112f150c6bf3f757d660f0f3ce1/lib/kruptein.js#L401)\n\n\n🌱 Output\n------\nThe `.set()` method output depends on three factors; the `encodeas`, `algorithm` and `use_asn1`.\n\nFor any algorithm that supports authentication (AEAD), the object structure includes the `Authentication Tag` and the `Additional\nAuthentication Data` attribute and value.\n\nWhen the `use_asn1` option is enabled (default is true), the result is an [ASN.1](https://letsencrypt.org/docs/a-warm-welcome-to-asn1-and-der/) value using the `encodeas` value. While this is a more complex encoding option, it helps standardize & minimize the size of the resulting ciphertext output.\n\n\n🧪 Test harness\n------------\nThe included test harness, invoked with `npm test`, makes every attempt to trap and handle errors. Some of which come from side channel or possible malability of the resultant ciphertext.\n\nThis can be seen within the `test/index.js` CI test harness under the HMAC, AT & AAD validation test cases.\n\n📊 Benchmark harness\n------------\nRun `npm run bench` for a human-readable benchmark report or `npm run bench:json` for JSON output.\n\nThe benchmark measures per-case wall time, CPU, memory, process disk I/O and, when available, GPU telemetry.\n\n\n🧠 References\n-----------------------\nThis module conforms to industry recommendations regarding algorithm type, mode, key size, iv size & implementation, digests, key  derivation & management etc. References used provided here:\n\n**RFC:**\n*   [RFC 2104](https://tools.ietf.org/html/rfc2104): HMAC: Keyed-Hashing for Message Authentication\n*   [RFC 4086](https://tools.ietf.org/html/rfc4086): Randomness Requirements for Security\n*   [RFC 5084](https://tools.ietf.org/html/rfc5084): Using AES-CCM and AES-GCM Authenticated Encryption\n*   [RFC 7914](https://tools.ietf.org/html/rfc7914): The scrypt Password-Based Key Derivation Function\n*   [RFC 8018](https://tools.ietf.org/html/rfc8018): Password-Based Cryptography Specification\n*   [RFC 9106](https://datatracker.ietf.org/doc/html/rfc9106): Argon2 Memory-Hard Function for Password Hashing and Proof-of-Work Applications\n*   [X.697](https://www.itu.int/rec/T-REC-X.697-201710-I/en): ASN.1 encoding rules: Specifications of JavaScript Object Notation Encoding Rules (JER)\n\n\n**NIST:**\n*   [SP 800-38A](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf): Block cipher modes of operation\n*   [SP 800-38B](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38d.pdf): Recommendation for Block Cipher Modes of Operation: Galois/Counter Mode (GCM) and GMAC\n*   [SP 800-57P1](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf): Recommendations for key management\n*   [SP 800-107](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-107r1.pdf): Recommendation for Applications Using Approved Hash Algorithms\n*   [SP 800-108](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-108.pdf): Recommendation for Key Derivation Using Pseudorandom Functions\n*   [SP 800-131A](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-131Ar2.pdf): Transitioning the Use of Cryptographic Algorithms and Key Lengths\n*   [SP 800-132](https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-132.pdf): Recommendation for Password-Based Key Derivation\n*   [SP 800-175B](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-175B.pdf): Guideline for Using Cryptographic Standards in the Federal Government\n\n\n**FIPS:**\n*   [FIPS 197](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.197.pdf): Advanced Encryption Standard (AES)\n*   [FIPS 198-1](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.198-1.pdf): The Keyed-Hash Message Authentication Code (HMAC)\n*   [FIPS 180-4](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf): Secure Hash Standard (SHS)\n*   [FIPS 186-5](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-5.pdf): Digital Signature Standard (DSS)\n\n\n📡 Contributing\n------------\nContributions are welcome & appreciated!\n\nRefer to the [contributing document](https://github.com/jas-/kruptein/blob/master/CONTRIBUTING.md) to help facilitate pull requests.\n\n\n📑 License\n-------\nThis software is licensed under the [MIT License](https://github.com/jas-/kruptein/blob/master/LICENSE).\n\nCopyright Jason Gerfen, 2019.\n","publish_time":1763464013254,"_cnpm_publish_time":1763464013254,"dist-tags":{"latest":"4.0.1"}}