Regular expression for matching SHA hashes in strings.
~ ❯❯❯ npm install sha-regex
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']
Returns a regex for matching SHA hashes.
Type: Object
Type: boolean
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.
Returns a regex for matching specific SHA version hashes.
Type: integer
Supported Versions: 1
, 224
, 256
, 384
, 512
Match a specific version of SHA.
Type: Object
Type: boolean
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.
MIT © Nikolaos Kamarinakis