| After getting slammed two successive days earlier this week with Comment Spams for Sex Sites I took an hour to implement CAPTCHA on my blog. I based the component on Chris Kunicki's .text implementation described in his blog here and here, and on "BrainJar's" CAPTCHA Image component described in his Code Project article here. Thank you Chris and BrainJar!
I took the GenerateRandomCode() component from the Default.aspx.cs in BrainJar's code and moved it to .Text UIData.cs class in Dottext.Web.UI Namespace and while I was at it made it static. (Responders to Chris' source post couldn't find the method from the BrainJar class.)
private static Random random = new Random();
public static string GenerateRandomCode() { string s = ""; for (int i = 0; i < 3; i++) s = String.Concat(s, random.Next(10).ToString()); return s; }
Then I changed Chris's code to generate the AreYouHuman cookie value from this method.
Response.Cookies["AreYouHuman"].Value = UIData.GenerateRandomCode();
Besides that, I changed the source generating the Image in JpegImage.aspx.cs so the numbers would be a bit more readable. All in all, cool AND fun. |
 |
|