Overview
SHA1 Hash: | b189acfd7b9209ac251e8c22060ce4453c2f41e7 |
---|---|
Date: | 2009-08-10 02:52:27 |
User: | drh |
Comment: | Add a new more legible ascii-art font to the anonymous login captcha. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/captcha.c from [0fc3d0dfef] to [d47d9e7153].
@@ -28,11 +28,11 @@ #include <assert.h> #include "config.h" #include "captcha.h" #if INTERFACE -#define CAPTCHA 2 /* Which captcha rendering to use */ +#define CAPTCHA 3 /* Which captcha rendering to use */ #endif /* ** Convert a hex digit into a value between 0 and 15 */ @@ -70,11 +70,11 @@ 0xf8e88f, 0xf8e888, }; /* -** Render a 32-bit unsigned integer as an 8-digit ascii-art hex number. +** Render an 8-character hexadecimal string as ascii art. ** Space to hold the result is obtained from malloc() and should be freed ** by the caller. */ char *captcha_render(const char *zPw){ char *z = malloc( 500 ); @@ -203,11 +203,11 @@ "| _| ", "|_| ", }; /* -** Render a 32-bit unsigned integer as an 8-digit ascii-art hex number. +** Render an 8-digit hexadecimal string as ascii arg. ** Space to hold the result is obtained from malloc() and should be freed ** by the caller. */ char *captcha_render(const char *zPw){ char *z = malloc( 300 ); @@ -227,10 +227,167 @@ } z[k] = 0; return z; } #endif /* CAPTCHA==2 */ + +#if CAPTCHA==3 +static const char *azFont3[] = { + /* 0 */ + " ___ ", + " / _ \\ ", + "| | | |", + "| | | |", + "| |_| |", + " \\___/ ", + + /* 1 */ + " __ ", + "/_ |", + " | |", + " | |", + " | |", + " |_|", + + /* 2 */ + " ___ ", + "|__ \\ ", + " ) |", + " / / ", + " / /_ ", + "|____|", + + /* 3 */ + " ____ ", + "|___ \\ ", + " __) |", + " |__ < ", + " ___) |", + "|____/ ", + + /* 4 */ + " _ _ ", + "| || | ", + "| || |_ ", + "|__ _|", + " | | ", + " |_| ", + + /* 5 */ + " _____ ", + "| ____|", + "| |__ ", + "|___ \\ ", + " ___) |", + "|____/ ", + + /* 6 */ + " __ ", + " / / ", + " / /_ ", + "| '_ \\ ", + "| (_) |", + " \\___/ ", + + /* 7 */ + " ______ ", + "|____ |", + " / / ", + " / / ", + " / / ", + " /_/ ", + + /* 8 */ + " ___ ", + " / _ \\ ", + "| (_) |", + " > _ < ", + "| (_) |", + " \\___/ ", + + /* 9 */ + " ___ ", + " / _ \\ ", + "| (_) |", + " \\__, |", + " / / ", + " /_/ ", + + /* A */ + " ", + " /\\ ", + " / \\ ", + " / /\\ \\ ", + " / ____ \\ ", + "/_/ \\_\\", + + /* B */ + " ____ ", + "| _ \\ ", + "| |_) |", + "| _ < ", + "| |_) |", + "|____/ ", + + /* C */ + " _____ ", + " / ____|", + "| | ", + "| | ", + "| |____ ", + " \\_____|", + + /* D */ + " _____ ", + "| __ \\ ", + "| | | |", + "| | | |", + "| |__| |", + "|_____/ ", + + /* E */ + " ______ ", + "| ____|", + "| |__ ", + "| __| ", + "| |____ ", + "|______|", + + /* F */ + " ______ ", + "| ____|", + "| |__ ", + "| __| ", + "| | ", + "|_| ", +}; + +/* +** Render an 8-digit hexadecimal string as ascii arg. +** Space to hold the result is obtained from malloc() and should be freed +** by the caller. +*/ +char *captcha_render(const char *zPw){ + char *z = malloc( 600 ); + int i, j, k, m; + const char *zChar; + + k = 0; + for(i=0; i<6; i++){ + for(j=0; j<8; j++){ + unsigned char v = hexValue(zPw[j]); + zChar = azFont3[6*v + i]; + for(m=0; zChar[m]; m++){ + z[k++] = zChar[m]; + } + } + z[k++] = '\n'; + } + z[k] = 0; + return z; +} +#endif /* CAPTCHA==3 */ /* ** COMMAND: test-captcha */ void test_captcha(void){