# sha-regex

> Regular expression for matching SHA hashes in strings.

Latest version **1.0.12** (published 2020-08-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install sha-regex
pnpm add sha-regex
yarn add sha-regex
bun add sha-regex
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2020-08-08 |
| First published | 2018-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Nikolaos Kamarinakis |
| Maintainers | k4m4 |
| Keywords | sha, regex |

## Links

- npm: https://www.npmjs.com/package/sha-regex
- Repository: https://github.com/k4m4/sha-regex
- Homepage: https://github.com/k4m4/sha-regex#readme
- Issues: https://github.com/k4m4/sha-regex/issues
- npm.io page: https://npm.io/package/sha-regex

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.0.12 (latest) — 2020-08-08
- 1.0.11 — 2020-04-04
- 1.0.10 — 2019-12-09
- 1.0.9 — 2019-12-09
- 1.0.8 — 2019-10-20
- 1.0.7 — 2019-07-13
- 1.0.6 — 2019-07-13
- 1.0.5 — 2019-06-05
- 1.0.4 — 2019-02-10
- 1.0.3 — 2018-10-12
- 1.0.2 — 2018-04-11
- 1.0.1 — 2018-04-11
- 1.0.0 — 2018-03-25

## README

# sha-regex [![Build Status](https://travis-ci.org/k4m4/sha-regex.svg?branch=master)](https://travis-ci.org/k4m4/sha-regex) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)

> Regular expression for matching SHA hashes in strings.


## Install

```
~ ❯❯❯ npm install sha-regex
```


## Usage

```js
const sha = require('sha-regex')

sha().test('nodejsrocks 84de6753b298abd027fcd1d790eade2413eafb5a')
//=> true

sha({exact: true}).test('nodejsrocks 84de6753b298abd027fcd1d790eade2413eafb5a foo')
//=> false

sha({exact: true}).test('84de6753b298abd027fcd1d790eade2413eafb5a')
//=> true

sha.version(256, {exact: true}).test('c6cb50e7eea0df1fd3eaf52ada2358f5423afd7c0b5ee2395231a9b3208ffcaf')
//=> true

sha.version(512, {exact: true}).test('84de6753b298abd027fcd1d790eade2413eafb5a')
//=> false

'nodejsrocks 	84de6753b298abd027fcd1d790eade2413eafb5a rainbow c6cb50e7eea0df1fd3eaf52ada2358f5423afd7c0b5ee2395231a9b3208ffcaf'.match(sha())
//=> ['84de6753b298abd027fcd1d790eade2413eafb5a','c6cb50e7eea0df1fd3eaf52ada2358f5423afd7c0b5ee2395231a9b3208ffca']
```


## API

### sha([options])

Returns a regex for matching SHA hashes.

#### options

Type: `Object`

##### exact

Type: `boolean`<br>
Default: `false` *(Matches any SHA hash in a string)*

Only match an exact string. Useful with `RegExp#test()` to check if a string is a SHA hash.


### sha.version(version, [options])

Returns a regex for matching specific SHA version hashes.

#### version

Type: `integer`<br>
Supported Versions: `1`, `224`, `256`, `384`, `512`

Match a specific version of SHA.

#### options

Type: `Object`

##### exact

Type: `boolean`<br>
Default: `false` *(Matches any SHA hash in a string)*

Only match an exact string. Useful with `RegExp#test()` to check if a string is a SHA hash.


## License

MIT © [Nikolaos Kamarinakis](https://nikolaskama.me)

---
_Source: https://npm.io/package/sha-regex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
