C语言实现用随机字符串生成验证码图片

就是正常的验证码逻辑——随机生成一个四位字符串,然后用这个字符串加随机干扰像素随机位置随机颜色之类的信息生成一张验证码图片!!!求大神帮忙········(新人暂无法悬赏,后期一定补上)

随机生成UUID的方法可以结合使用

#include <stdio.h>
#include <stdlib.h>

/**
 * Create random UUID
 *
 * @param buf - buffer to be filled with the uuid string
 */
char *random_uuid( char buf[37] )
{
    const char *c = "89ab";
    char *p = buf;
    int n;

    for( n = 0; n < 16; ++n )
    {
        int b = rand()%255;

        switch( n )
        {
            case 6:
                sprintf(
                    p,
                    "4%x",
                    b%15 );
                break;
            case 8:
                sprintf(
                    p,
                    "%c%x",
                    c[rand()%strlen( c )],
                    b%15 );
                break;
            default:
                sprintf(
                    p,
                    "%02x",
                    b );
                break;
        }

        p += 2;

        switch( n )
        {
            case 3:
            case 5:
            case 7:
            case 9:
                *p++ = '-';
                break;
        }
    }

    *p = 0;

    return buf;
}

结合楼上的uuid生成,我之前写过一个opencv数字生成图片的博客,两者结合能够满足楼主需要:
http://blog.csdn.net/wangyaninglm/article/details/44161235