Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
captcha-lite
Advanced tools
Lite captcha generator by Pure Javascript.
node-captcha-lite just extends node-pnglib, you can check its document for constructor options since we only add some public methods on it.
Let's try to draw number:
'use strict';
const fs = require('fs');
const path = require('path');
const Captcha = require('..');
const FONTS = Captcha.FONTS;
function rand(min, max) {
let comp = max - min;
return (Math.random() * comp + min) | 0;
}
function getRandFont(fonts) {
const fontNames = Object.keys(fonts);
return fonts[fontNames[rand(0, fontNames.length)]];
}
let png = new Captcha(200, 100, 8, [255, 255, 255, 255]);
let chars = getRandFont(FONTS).chars;
for (let i = 0; i < chars.length; ++i) {
let font = getRandFont(FONTS);
let ch = chars[i];
png.drawChar(ch, 0 + 2 * i * font.w, 50, font, '#00FF00');
}
fs.writeFileSync(path.resolve(__dirname, './char.png'), png.getBuffer());
Output:
Let's try to draw bezier curve:
'use strict';
const fs = require('fs');
const path = require('path');
const Captcha = require('..');
const png = new Captcha(300, 300, 8, [255,255,255,255]);
const bezierPoints = [
[250, 50],
[250, 250],
[260, 70],
[60, 70]
];
png.drawBezier(bezierPoints, {
tolerance: 0, // 曲线线条扩宽的距离
step: 1/1000, // 每两个点之间绘制1000个点
fixEndPointCurve: true, // 是否绘制开始和结束点的曲线
handlerRatio: 0.5, // 贝塞尔曲线的句柄长度(连续贝塞尔模型)
color: '#cc0044' // 曲线的颜色
});
fs.writeFileSync(path.resolve(__dirname, './bezier.png'), png.getBuffer());
Output:
FAQs
Lite captcha generator by Pure Javascript.
The npm package captcha-lite receives a total of 12 weekly downloads. As such, captcha-lite popularity was classified as not popular.
We found that captcha-lite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.