# hashing

Rule `sonarjs/hashing`. Weak hashing algorithms should not be used

- 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: #1222 by reach, #523 by growth

## Linters

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

## Code examples

### Correct: the rule accepts this

```js
const crypto = require("crypto");

const hash = crypto.createHash('sha512'); // Compliant
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/hashing": "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/hardcoded-secret-signatures](https://lintradar.dev/rules/sonarjs/hardcoded-secret-signatures.md): Credentials should not be hard-coded
- [sonarjs/hooks-before-test-cases](https://lintradar.dev/rules/sonarjs/hooks-before-test-cases.md): Lifecycle hooks should not be interleaved with test cases or nested suites
- [sonarjs/generator-without-yield](https://lintradar.dev/rules/sonarjs/generator-without-yield.md): Generators should explicitly "yield" a value
- [sonarjs/in-operator-type-error](https://lintradar.dev/rules/sonarjs/in-operator-type-error.md): "in" should not be used with primitive types
- [sonarjs/future-reserved-words](https://lintradar.dev/rules/sonarjs/future-reserved-words.md): Future reserved words should not be used as identifiers
- [sonarjs/inconsistent-function-call](https://lintradar.dev/rules/sonarjs/inconsistent-function-call.md): Functions should be called consistently with or without "new"

---

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