C 语言的 GD 验证码生成器
我正在用 C 语言为我的网站编写一个 fastcgi 应用程序。
如何使用 GD 生成验证码图像?
我在谷歌上徒劳地搜索了一些东西(搜索仍在进行中),但如果有人能给我有关该过程的基本想法,那就太好了。
对于随机数,我将使用纳秒作为种子(或使用它本身)。
提前致谢。
I'm writing a fastcgi app for my website in C.
How do I use GD to generate a CAPTCHA image?
I searched for some stuff on google in vain (still search is going on), but it would be nice if someone could give me the basic idea about the procedure.
For random numbers, I will use nanoseconds as seed (or use that itself).
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 void gdImageStringUp(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char *s, int color) (FUNCTION) 代码示例(您几乎可以复制粘贴它)。
http://www.libgd.org/Font
噪声是通过随机像素/线条/等完成的,这很简单:
http://www.libgd.org/Drawing
LibGD 有无数的例子在他们的网站上。
Look at the
void gdImageStringUp(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char *s, int color) (FUNCTION)
code example (you can pretty much copy-paste it)..http://www.libgd.org/Font
The noise is done with random pixels/lines/etc, which is trivial:
http://www.libgd.org/Drawing
LibGD has like a zillion examples on their website.
我不确定 GD 是什么,但我假设它是某种图像库,但我可以给你一个关于实现整个验证码的想法:
标签链接到您的 cgi 应用程序并发送“种子”参数。请注意,由于第二步,您从 php 代码中编写了种子。
至于来自种子的验证码生成器,类似这样的东西应该足够了:
I'm not sure what GD is but I'm assuming it's some sort of an image library, but I can give you an idea about implementing the whole captcha thing:
<img>
tag that links to your cgi app and sends a "seed" parameter. You write the seed from the php code mind you, because of the 2nd step.As for a captcha generator from a seed, something like this should suffice: