2.0.0 • Published 5 years ago

bruter v2.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Brute force algorithm via js generator

Install

npm install bruter

Usage

Basic example

const bruteForce = require('bruter')
const alphabet = 'abc'

for (const chars of bruteForce({alphabet})) {
	console.log(chars)

	if (chars === 'aba') {
		break
	}
}

Continue from certain position

const bruteForce = require('bruter')
const alphabet = 'abc'
const from = 5

for (const chars of bruteForce({
	alphabet,
	from,
})) {
	console.log(chars)

	if (chars === 'aba') {
		break
	}
}

Brute in some range

It's useful to brute via several nodes parallel.

const bruteForce = require('bruter')
const alphabet = 'abc'
const from = 5
const to = 10

for (const chars of bruteForce({
	alphabet,
	from,
	to,
})) {
	console.log(chars)

	if (chars === 'aba') {
		break
	}
}