daniel-e / captcha

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

Can only generate blank PNGs #14

Closed nmattia closed 2 years ago

nmattia commented 2 years ago

The following code only ever generates blank PNGs (of the correct dimension):

let chars = "FOO".chars().collect::<Vec<char>>();
let captcha = captcha.set_chars(&chars).view(220, 120);
// do something useful with captcha.as_base64()

Everything seems to work, no error message. Here's what I get when I print the supported_chars:

2fJUryFSQc6MvhwDaiuNXWxeBqTj9b8mCd54HnPG7k3lVt1AEZgKpsYRz

Any idea what may be going wrong?

nmattia commented 2 years ago

Ok, I misunderstood set_chars. From the doc:

Sets the characters that should be used when generating a CAPTCHA.

It doesn't write chars to the captcha, but specifies which chars can be used. Silly me.