Captchas

From no name for this wiki
Jump to: navigation, search

Gratis Captcha auf http://www.captchas.net.

Anbei die Validierung in C#:

public static class CaptchaValidator
    {
        public static string[] alphabet = { "a", "b", "c", "d", "e", "f", 
                                            "g", "h", "i", "j", "k", "l", 
                                            "m", "n", "o", "p", "q", "r", 
                                            "s", "t", "u", "v", "w", "x", 
                                            "y", "z" };
 
 
        public static string GetValidationString(string secret, string zufall)
        {                      
            string toEncode = secret + zufall;
            byte[] hash = MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(toEncode));
            StringBuilder sb = new StringBuilder(6);
            for (int i = 0; i < 6; i++)
            {
                int letterNum = hash[i] % 26;
                string a = alphabet[letterNum];
                sb.Append(a);
            }
            return sb.ToString();
        }
}