【问题标题】:Simple Math based captcha基于简单数学的验证码
【发布时间】:2012-12-21 02:15:47
【问题描述】:

reCaptcha 现在很难阅读(实际上是破译)。所以我正在寻找一个替代的验证码系统来使用。

我正在考虑使用一个简单的基于数学的系统,例如:“What is 2+5”。

有没有这样的插件,或者,关于如何构建我自己的想法?

(不复杂的数学like this one

【问题讨论】:

    标签: asp.net-mvc-3 validation captcha recaptcha


    【解决方案1】:

    PHP - 生成一个简单的加法或减法数学问题,在显示数字 (10 - 3) 和单词(七加五)之间随机交替,并以数字 (14) 或单词形式 (14) 接受答案。返回一个表示方程分量的数组

    [0] - 第一个变量值,作为字符串,如 '4' 或 'four' [1] - 第二个值,运算符,如 '+' 或 'plus' [2] - 第三个值,第二个变量,如 '10' 或 '10' [3] - 数字形式的答案,例如“14” [4] - 答案,文本形式,如“十四”

    所以只需将方程式打印到页面上,将数组存储在 $_SESSION 中,然后检查用户提供的答案。

    <?php
    
    // array of numbers and their corresponding word versions
    // you can simply do $wordNumbers[6] and get 'six'
    $wordNumbers = array(
        0 => 'zero',
        1 => 'one',
        2 => 'two',
        3 => 'three',
        4 => 'four',
        5 => 'five',
        6 => 'six',
        7 => 'seven',
        8 => 'eight',
        9 => 'nine',
        10 => 'ten',
        11 => 'eleven',
        12 => 'twelve',
        13 => 'thirteen',
        14 => 'fourteen',
        15 => 'fifteen',
        16 => 'sixteen',
        17 => 'seventeen',
        18 => 'eighteen',
        19 => 'nineteen', 
        20 => 'twenty'
    );
    
    /*
     * 
     * returns an array representing components of a math captcha
     *  [0] - first variable value, as string, like either '4' or 'four'
     *  [1] - second value, the operator, like '+' or 'plus'
     *  [2] - third value, the second variable, like 'ten' or '10'
     *  [3] - the answer, in numerical form, like '14'
     *  [4] - the answer, in text form, like 'fourteen'
     */
    function getMathCaptcha(){
    
        global $wordNumbers;
    
        $equation = array();
    
        // get first number, between 7 and 13 inclusive
        $n1 = rand(7, 13);
        $r = rand(0,1);
        // return $n1 as digit or text
        if ($r == 0) {
            $equation[0] = $n1;
        } else {
            $equation[0] = $wordNumbers[$n1];
        }
    
        // get operator
        $o = rand(0,1);
        $r = rand(0,1);
        if ($o == 0){
            // subtraction
            if ($r == 0) {
                $equation[1] = '-';
            } else {
                $equation[1] = 'minus';
            }
        } else {
            // addition
            if ($r == 0) {
                $equation[1] = '+';
            } else {
                $equation[1] = 'plus';
            }
        }
    
        // get second number, between 0 and 7 inclusive, so no negative answers
        $n2 = rand(1,7);
        $r = rand(0,1);
        // return $n2 as digit or text
        if ($r == 0) {
            $equation[2] = $n2;
        } else {
            $equation[2] = $wordNumbers[$n2];
        }
    
        // get answer
        if ($o == 0){
            $answer = $n1 - $n2;
        } else {
            $answer = $n1 + $n2;
        }
    
        // answer as digit and text
        $equation[3] = $answer;
        $equation[4] = $wordNumbers[$answer];
    
    
        return $equation;
    
    }
    
    
    ?>
    

    【讨论】:

    • 从 ASP.NET 标签来看,你不是在 PHP 中工作,但逻辑很明显,应该很容易移植到你喜欢的任何语言。
    【解决方案2】:

    你试过像我下面这样的验证码方法吗?

    what are the downpoints of this captcha method

    或者您是否特别想使用用户输入方法?

    【讨论】:

      【解决方案3】:

      Captchator怎么样?

      它很容易实现,而且很有效!那里还有 PHP 和 Ruby 的代码示例,用其他语言实现应该不难。

      基于数学的验证码很弱且容易通过,那里有很多垃圾邮件机器人知道如何做数学:)

      【讨论】:

        【解决方案4】:

        如果我要制作一个简单的,它会遵循:

        制作不同类别的物品,例如鲜花、水果、蔬菜和肉类。然后设计验证码以要求总共一个类别。

        例如:

        随机化类别,选择 2 个独特的类别。那么也许我们得到了鲜花和水果。接下来,问用户:“如果你有 3 朵玫瑰、4 个橙子和 6 个苹果,那么你有多少水果?”

        简单模式:

        获取 n-1 个唯一类别。显示 n 个项目,其中每个项目属于唯一类别之一。要求一个类别的总数。

        【讨论】:

          【解决方案5】:

          您可以自己创建这样的验证码。您所要做的就是创建一个函数,该函数将在给定的数字列表之间选取一个随机数,然后调用该函数两次以获取两个随机数。

          将结果存储在会话变量或任何其他变量中,以便以后验证。

          下面是一个用c#编码的例子

              Random a=new Random();
              a.Next();//it will return you a non negative number
              a.Next(min value,maximum value);//it will return you a number between the range specified.
          

          希望对你有帮助

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2013-03-04
            • 2011-06-25
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多