Generated by GPT-5-mini| crypto (Node.js) | |
|---|---|
| Name | crypto (Node.js) |
| Developer | Node.js Foundation |
| Initial release | 2009 |
| Programming language | C++, JavaScript |
| Platform | Linux, Windows, macOS |
| License | MIT |
crypto (Node.js) The crypto module in Node.js provides cryptographic functionality that binds to underlying libraries and CPU features to perform hashing, encryption, signing, and key management. It is maintained as part of the Node.js project and is used across projects from server frameworks to tooling and platforms. Implementations rely on native libraries and standards referenced in IETF, W3C, and NIST documents and are deployed by organizations such as IBM, Microsoft, Google, and Amazon.
The module originated within the Node.js runtime and interfaces with native libraries like OpenSSL and LibreSSL while aligning with standards from IETF, NIST, and W3C. Major contributors and stakeholders include the Node.js Foundation, Joyent, IBM, Microsoft, Google, Red Hat, and the Linux Foundation; maintainers follow release practices similar to those in Chromium, Firefox, and WebKit. The crypto API is exposed on the global object in server-side applications using frameworks such as Express.js, Koa, NestJS, and Hapi, and it integrates with build systems and CI providers including Jenkins, Travis CI, GitHub Actions, and CircleCI.
The core exports include interfaces used by developers in applications like npm, yarn, webpack, and Rollup: Cipher, Decipher, Hash, Hmac, Sign, Verify, DiffieHellman, ECDH, KeyObject, and randomBytes. These primitives are consumed by higher-level libraries such as bcrypt, scrypt, libsodium wrappers, OpenSSL-based bindings, and TLS implementations used by OpenSSL, BoringSSL, and LibreSSL. The API surface mirrors capabilities found in Web Crypto API proposals and browser implementations like Chromium, Firefox, and Safari to ease cross-platform portability for projects such as Electron, NW.js, and Cloudflare Workers.
Supported algorithms reflect standards and algorithms published by NIST, IETF, and ISO: AES (CBC, GCM), RSA (PKCS#1, OAEP), ECDSA, Ed25519, SHA-1, SHA-2 family, SHA-3, HMAC, HKDF, PBKDF2, and ChaCha20-Poly1305. Implementations rely on OpenSSL versions that determine available ciphers and curves such as secp256k1, secp384r1, and Curve25519 used in protocols like TLS, SSH, and IPsec. The module provides interfaces for symmetric encryption, asymmetric encryption, authenticated encryption, digital signatures, and key derivation that are comparable to primitives used in projects like OpenPGP, TLS implementations in OpenSSL and BoringSSL, and cryptographic libraries such as libsodium and Botan.
Key material is represented by KeyObject and supports PEM and DER formats interoperable with tools such as OpenSSL, GnuPG, PuTTY, and Windows Certificate Store. Practices for secure key management follow guidance from NIST SP 800-series, CIS Benchmarks, and OWASP recommendations; deployments often integrate with HSM vendors (Thales, AWS CloudHSM, Azure Key Vault, Google Cloud KMS) and PKI systems like Let's Encrypt, DigiCert, and Entrust. Secure defaults, constant-time operations, and mitigation against side-channel attacks are influenced by work from projects such as BoringSSL, libsodium, and projects led by researchers affiliated with MIT, Stanford, and UC Berkeley.
Performance characteristics depend on OpenSSL versions, CPU features (AES-NI, AVX2, NEON), and platform-specific optimizations present in Linux kernel, Windows Server, and macOS. Benchmarks are commonly run against alternatives like OpenSSL, BoringSSL, LibreSSL, and libsodium and are used by projects including NGINX, HAProxy, Envoy, and Istio to tune TLS and crypto paths. Node.js integrates with V8 for JIT behavior and may use native add-ons via N-API or Node-API for accelerated operations; large-scale deployments from companies such as Netflix, LinkedIn, and PayPal emphasize throughput, latency, and TLS session resumption.
Typical uses include HTTPS/TLS termination in servers like nginx and Apache, JWT signing and verification in frameworks such as Express.js and Fastify, password hashing with bcrypt and scrypt in authentication systems used by Facebook, Twitter, and GitHub, and end-to-end encryption in messaging projects like Signal, Matrix, and WhatsApp. Other use cases encompass secure storage and secrets management in HashiCorp Vault, Kubernetes Secrets, Docker, and CI/CD pipelines used by Travis CI, GitLab CI, and GitHub Actions, as well as blockchain and cryptocurrency tooling interfacing with Ethereum, Bitcoin Core, Hyperledger, and Solana tooling.
Behavior and available algorithms vary across Node.js LTS versions and OpenSSL releases; migration paths are documented in Node.js release notes and involve projects such as Electron, NW.js, and native modules using node-gyp. Breaking changes historically required coordinated updates across package ecosystems like npm, yarn, webpack, Babel, and TypeScript, and interoperability testing with client platforms such as Chrome, Firefox, Safari, Android, and iOS is common. Enterprises relying on distributions from Red Hat, Debian, Ubuntu, and CentOS and cloud vendors AWS, Azure, and Google Cloud must plan for OpenSSL ABI changes and coordinate with security teams and vendors such as Red Hat, Canonical, and Microsoft.