#security #captcha #back-end #protection #client-server

hcaptcha

hCaptcha client response verification. Validate the hCaptcha response submitted from to your server from the client.

29 stable releases

2.7.6 Oct 24, 2024
2.5.0 Sep 14, 2024
2.4.4 Jul 27, 2024
2.3.1 Jan 27, 2024
0.4.0 Nov 23, 2020

#126 in Web programming

Download history 211/week @ 2024-07-29 121/week @ 2024-08-05 206/week @ 2024-08-12 16/week @ 2024-08-19 195/week @ 2024-08-26 188/week @ 2024-09-02 187/week @ 2024-09-09 119/week @ 2024-09-16 1480/week @ 2024-09-23 169/week @ 2024-09-30 195/week @ 2024-10-07 586/week @ 2024-10-14 2404/week @ 2024-10-21 267/week @ 2024-10-28 534/week @ 2024-11-04 261/week @ 2024-11-11

3,513 downloads per month

MIT/Apache

110KB
1.5K SLoC

Rust library hcaptcha

Crates.io MIT licensed Build Status Rust 1.75+ Docs BuyMeaCoffee GitHubSponsors

The rust library hcaptcha is used with your backend service to verify the hcaptcha response provided from the client.

Installation

To use hcaptcha, add the following to your Cargo.toml:

[dependencies]
hcaptcha = "2.7.6"

Usage

Derive a validation method on the data structure representing your data, marking the captcha components in the data structure.

# use hcaptcha::Hcaptcha;

#[derive(Debug, Deserialize, Hcaptcha)]
pub struct ContactForm {
    name: String,
    phone: String,
    email: String,
    message: String,
    #[captcha]
    token: String,
}

Validate the captcha data.

    # #[tokio::main]
    # async main() -> Result<(), Box<dyn std::error::Error>> {
    let contact_form: ContactForm = serde_json::from_str(e.body_string())?;
    contact_form.valid_response(&secret, None).await?;
    # }
    # fn get_your_secret() -> String {
    #   "0x123456789abcde0f123456789abcdef012345678".to_string()
    # }

See the examples folder for an AWS Lambda contact form example.

Web Assembly

Hcaptcha has been tested in a web assembly project using wasm-bindgen and node.

See the hcaptcha-wasm example for a sample project which can be run using wasm-pack test --node.

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Credits

Initial version based on recaptcha-rs by panicbit.

Dependencies

~5–17MB
~244K SLoC