
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
captcha-generator-react
Advanced tools
A lightweight utility to generate image-based captchas using the HTML5 Canvas API. Returns a base64 image and the corresponding captcha text for easy verification.
A lightweight utility to generate image-based captchas using the HTML5 Canvas API. Returns a base64 image and the corresponding captcha text for easy verification.
Using npm
npm install captcha-generator-react
Using pnpm
pnpm add captcha-generator-react
import generateCaptcha from "generate-captcha";
import { useEffect, useState } from "react";
function CaptchaGenerator() {
const [captcha, setCaptcha] = useState("");
const [captchaText, setCaptchaText] = useState("");
const [captchaImage, setCaptchaImage] = useState(null);
useEffect(() => {
const { text, imgUrl } = generateCaptcha();
setCaptchaText(text);
setCaptchaImage(imgUrl);
}, []);
return (
<>
<img src={captchaImage || undefined} alt="" className="mb" />
<form
onSubmit={(e) => {
e.preventDefault();
if (captchaText === captcha) {
alert("success");
} else {
alert("fail");
}
}}
>
<input
type="text"
name="captcha"
onChange={(e) => {
setCaptcha(e.target.value);
}}
/>
<button>Submit</button>
</form>
</>
);
}
export default CaptchaGenerator;
"use client";
import generateCaptcha from "generate-captcha";
import { useEffect, useState } from "react";
function CaptchaGenerator() {
const [captcha, setCaptcha] = useState("");
const [captchaText, setCaptchaText] = useState("");
const [captchaImage, setCaptchaImage] = useState(null);
useEffect(() => {
const { text, imgUrl } = generateCaptcha();
setCaptchaText(text);
setCaptchaImage(imgUrl);
}, []);
return (
<>
<img src={captchaImage || undefined} alt="" className="mb" />
<form
onSubmit={(e) => {
e.preventDefault();
if (captchaText === captcha) {
alert("success");
} else {
alert("fail");
}
}}
>
<input
type="text"
name="captcha"
onChange={(e) => {
setCaptcha(e.target.value);
}}
/>
<button>Submit</button>
</form>
</>
);
}
export default CaptchaGenerator;
if you want to adjust the height, width or length of the captcha, just include it as an object in the generateCaptcha() function's parameter.
const { text, imgUrl } = generateCaptcha({ length: 4 }); // generates a captcha of 4 characters.
const { text, imgUrl } = generateCaptcha({ length: 7, height: 50, width: 220 }); // generates a captcha where the height is 50 pixels, width is 220 pixels and the length is 7.
FAQs
A lightweight utility to generate image-based captchas using the HTML5 Canvas API. Returns a base64 image and the corresponding captcha text for easy verification.
The npm package captcha-generator-react receives a total of 5 weekly downloads. As such, captcha-generator-react popularity was classified as not popular.
We found that captcha-generator-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.