Crates.io | ic-captcha |
lib.rs | ic-captcha |
version | 1.0.0 |
source | src |
created_at | 2024-02-29 13:06:40.207475 |
updated_at | 2024-03-01 02:04:53.241607 |
description | Generating CAPTCHAs with given random bytes for the Internet Computer. |
homepage | |
repository | https://github.com/ldclabs/ic-captcha |
max_upload_size | |
id | 1157767 |
size | 99,067 |
ic-captcha is a library that generating CAPTCHAs with given random bytes for the Internet Computer.
It is inspired by captcha-rs.
See examples and the API documentation for more.
CaptchaBuilder::mode | Captcha Preview |
---|---|
mode(0): dark on light | |
mode(1): colorful on light | |
mode(2): colorful on dark |
CaptchaBuilder::complexity | Captcha Preview |
---|---|
complexity(1) | |
complexity(5) | |
complexity(10) |
Captcha::to_base64 | Captcha Preview |
---|---|
to_base64(10): 1.49KB | |
to_base64(40): 2.68KB | |
to_base64(80): 5.21KB |
Add the following dependency to the Cargo.toml file:
[dependencies]
ic-captcha = "1.0"
And then get started in main.rs
:
use ic_captcha::CaptchaBuilder;
fn main() {
{
let builder = CaptchaBuilder::new();
let captcha = builder.generate(b"random seed 0", None);
println!("text: {}", captcha.text());
println!("base_img: {}", captcha.to_base64(0));
let captcha = builder.generate(b"random seed 1", None);
println!("text: {}", captcha.text());
println!("base_img: {}", captcha.to_base64(0));
}
{
// same as default
let builder = CaptchaBuilder::new()
.length(4)
.width(140)
.height(60)
.mode(1)
.complexity(4);
let captcha = builder.generate(b"random seed 0", None);
println!("text: {}", captcha.text());
println!("base_img: {}", captcha.to_base64(30));
}
}
Copyright © 2024-present LDC Labs.
ldclabs/ic-captcha
is licensed under either of Apache License, Version
2.0.