Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nidrux/simple-captcha-generator

Generate a simple captcha string and or captcha image.
https://github.com/nidrux/simple-captcha-generator

captcha captcha-generator captcha-image javascript nodejs npm-package simple

Last synced: about 1 month ago
JSON representation

Generate a simple captcha string and or captcha image.

Awesome Lists containing this project

README

        

# simple-captcha-generator

Generate a simple captcha string and or captcha image.







### Installation

Type `npm i simple-captcha-generator` in your cmd to install the package

#### create captcha:
```js
const { Captcha } = require("simple-captcha-generator");
const captcha = new Captcha();
```

### Usage:

```js
const { Captcha }= require('simple-captcha-generator');
let captcha = new Captcha();

(async () => {
console.log(captcha.currentString);
console.log(await captcha.image(captcha.currentString));
})();
```

##### How to set string length?

You can have have a `min length of 5` and a `max length of 10`. When no length is specified it will default to 5. Every length above 10 will default to 10.

```js
const captcha = new Captcha(5);
```
### Options:

.currentString `string`

Returns a generated string with the given length

Example: '0e6ji'

.length `int`

Returns the given length

Example: 8

.image() `Buffer`

Returns and image buffer of the generated captcha (Promise so use await!)

Usage
```js
captcha.image(captcha.currentString) //Return image buffer of current generated string
```



### Example images: