daniel-e / captcha

CAPTCHA library written in Rust.
MIT License
98 stars 20 forks source link

feature request: as_base64() #4

Closed TheCGDF closed 4 years ago

TheCGDF commented 4 years ago

encode binary data with base64 so that the data can be contained in JSON easily. i think it is useful.

dessalines commented 4 years ago

I'd just use the base64 crate for this, I did this and its a one liner:

    let png_byte_array = captcha.as_png().expect("failed to generate captcha");
    let png = base64::encode(png_byte_array);
daniel-e commented 4 years ago

I justed added a method as_base64() which returns the a png encoded as base64. @TheCGDF thank you for your feature request and @dessalines thank you for your example.