Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ESLint plugin.
- [`chalk`](./chalk.md)
| [`core-util-is`](./core-util-is.md)
- [`cpx`](./cpx.md)
- [`crypto-js`](./crypto-js.md)
- [`deep-equal`](./deep-equal.md)
- [`depcheck`](./depcheck.md)
- [`dot-prop`](./dot-prop.md)
Expand Down
37 changes: 37 additions & 0 deletions docs/modules/crypto-js.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
description: Modern alternatives to the `crypto-js` package for cryptographic operations
---

# Replacements for `crypto-js`

`crypto-js` is no longer actively maintained and has been discontinued since engines now come with this functionality built-in.

## Node `node:crypto` (built-in)

Node provides a [`node:crypto`](https://nodejs.org/api/crypto.html) module as part of its standard library.

This supports hashes/HMAC, AES-GCM, PBKDF2/scrypt, RSA/ECDSA/Ed25519, and secure RNG.

```ts
import sha256 from 'crypto-js/sha256'; // [!code --]
import { createHash } from 'node:crypto'; // [!code ++]

const secret = 'abcdefg';
const hash = sha256(secret).toString(); // [!code --]
const hash = createHash('sha256') // [!code ++]
.update(secret) // [!code ++]
.digest('hex'); // [!code ++]
```

## Web Crypto API (native)

The [Web Crypto API](https://developer.mozilla.org/docs/Web/API/Web_Crypto_API) provides native functionality for cryptographic operations in both web browsers and Node.

> [!NOTE]
> A few legacy algorithms are intentionally omitted for security reasons (e.g. MD5).

## Bun (built-in)

Bun supports the Web Crypto API natively, and also provides support for streaming hashing via [`Bun.CryptoHasher`](https://bun.sh/docs/api/hashing).

As with the Web Crypto API, many legacy algorithms are intentionally omitted for security reasons (e.g. MD5).
6 changes: 6 additions & 0 deletions manifests/preferred.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
"docPath": "cpx",
"category": "preferred"
},
{
"type": "documented",
"moduleName": "crypto-js",
"docPath": "crypto-js",
"category": "preferred"
},
{
"type": "documented",
"moduleName": "deep-equal",
Expand Down