Giter Site home page Giter Site logo

hash-length-regex's Introduction

hash-length-regex Build Status XO code style

Retrieve the regular expression of a hash of specified bit-length.

Install

~ ❯❯❯ npm install hash-length-regex

Usage

const hashLengthRegex = require('hash-length-regex');

hashLengthRegex(128).test('nodejsrocks 1abcb33beeb811dca15f0ac3e47b88d9');
//=> true

hashLengthRegex(128, {exact: true}).test('nodejsrocks 1abcb33beeb811dca15f0ac3e47b88d9 foo');
//=> false

hashLengthRegex(256, {exact: true}).test('4696a780a2051b5a0f422970904da794adc1b499b2f4583e778e100a0bdd79cc');
//=> true

'nodejsrocks 1abcb33beeb811dca15f0ac3e47b88d9 rainbow 897b47d80a717715378832539b4c1340'.match(hashLengthRegex(128));
//=> ['1abcb33beeb811dca15f0ac3e47b88d9', '897b47d80a717715378832539b4c1340']

API

hashLengthRegex (bitLength, [options])

Returns a regular expression for matching hashes of the specified bit-length.

bitLength

Type: number

Number of bits of desired hash.

options

options.exact

Type: boolean Default: false (Matches any hash in a string)

Only match an exact string. Useful with RegExp#test() to check if a string is a hash of given bit-length.

License

MIT © Nikolaos Kamarinakis

hash-length-regex's People

Contributors

dependabot[bot] avatar k4m4 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.