#captcha

tiny_captcha

rust version tiny captcha

4 releases

0.1.4 Jun 24, 2022
0.1.3 Jun 24, 2022
0.1.2 Jun 24, 2022
0.1.1 Jun 24, 2022

#14 in #captcha

Apache-2.0

93KB
1.5K SLoC

tiny_captcha : rust 轻量级验证码生成器,可以编译成 wasm

→ 中文说明

tiny_captcha : rust lightweight captcha generator that compiles to wasm

Project documentation

Lightweight CAPTCHA generator, relying only on rand and gif, can be compiled into wasm.

Based on Ivan Tikhonov's captcha library, rewritten with c2rust code conversion.

The font file is from https://github.com/ITikhonov/captcha/blob/master/font.h and is ASCII artwork, make and then use unfont to generate the array.

Use the demo :

use anyhow::Result;
use std::{env::current_exe, fs::File};
use tiny_captcha::gif;

fn main() -> Result<()> {
  for i in 1..=10 {
    let exe = current_exe()?;
    let gif_path = exe.parent().unwrap().join(format!("{}.gif", i));

    let word = gif(&mut File::create(&gif_path)?);
    println!("{} {}", word, gif_path.display());
  }
  Ok(())
}

The output is shown :

tiny_captcha : rust 轻量级验证码生成器,可以编译成 wasm

项目文档

轻量级验证码生成器,仅依赖于 rand 和 gif ,可以编译成 wasm 。

Ivan Tikhonov 的验证码库 的基础上,用 c2rust 转代码后改写。

字体文件来自 https://github.com/ITikhonov/captcha/blob/master/font.h ,是 ASCII 艺术字 , make 之后用 unfont 生成数组。

使用演示 :

use anyhow::Result;
use std::{env::current_exe, fs::File};
use tiny_captcha::gif;

fn main() -> Result<()> {
  for i in 1..=10 {
    let exe = current_exe()?;
    let gif_path = exe.parent().unwrap().join(format!("{}.gif", i));

    let word = gif(&mut File::create(&gif_path)?);
    println!("{} {}", word, gif_path.display());
  }
  Ok(())
}

输出展示 :

关于

本项目隶属于 人民网络 (rmw.link) 代码计划。

人民网络

Dependencies

~0.5–1MB
~16K SLoC