# no-weak-cipher

Rule `sonarjs/no-weak-cipher`. Cipher algorithms should be robust

- Source: sonarjs
- Technologies: JavaScript
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1334 by reach, #635 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/no-weak-cipher` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-5547/) |

## Code examples

### Incorrect: the rule reports this

```js
crypto.createCipheriv("DES", key, iv); // Noncompliant: DES / 3DES is unsecure
crypto.createCipheriv("DES-EDE", key, ""); // Noncompliant: DES / 3DES is unsecure
crypto.createCipheriv("DES-EDE3", key, ""); // Noncompliant: DES / 3DES is unsecure
crypto.createCipheriv("RC2", key, iv); // Noncompliant: RC2 is vulnerable to a related-key attack
crypto.createCipheriv("RC4", key, "");// Noncompliant: RC4 is vulnerable to several attacks
crypto.createCipheriv("BF", key, iv);// Noncompliant: Blowfish use a 64-bit block size makes it vulnerable to birthday attacks
```

### Correct: the rule accepts this

```js
crypto.createCipheriv("AES-256-GCM", key, iv);
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/no-weak-cipher": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/no-vue-mixins](https://lintradar.dev/rules/sonarjs/no-vue-mixins.md): Vue components should not use mixins
- [sonarjs/no-weak-keys](https://lintradar.dev/rules/sonarjs/no-weak-keys.md): Cryptographic keys should be robust
- [sonarjs/no-vue-class-component](https://lintradar.dev/rules/sonarjs/no-vue-class-component.md): Vue components should not use the deprecated "vue-class-component" or "vue-property-decorator" libraries
- [sonarjs/non-existent-operator](https://lintradar.dev/rules/sonarjs/non-existent-operator.md): Non-existent operators '=+', '=-' and '=!' should not be used
- [sonarjs/no-useless-react-setstate](https://lintradar.dev/rules/sonarjs/no-useless-react-setstate.md): React state setter function should not be called with its matching state variable
- [sonarjs/null-dereference](https://lintradar.dev/rules/sonarjs/null-dereference.md): Properties of variables with "null" or "undefined" values should not be accessed

---

Web page: https://lintradar.dev/rules/sonarjs/no-weak-cipher. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
