zhangmo
int IsNumber(const char * authcode, int len)
{
    for (int i = 0; i < len; i++){
        if (authcode[i] >= \'0\'&&authcode[i] <= \'9\'){
            continue;
        }
        else{
            return i;
        }
    }
    return len;
}

BOOL IsValidAuthCode(const char * authcode, int len)
{
    int validLen = IsNumber(authcode, len);
    if (validLen < 16)
    {
        return false;
    }
    if (authcode[0] == \'1\')
    {
        //微信
        if (authcode[1] == \'0\'
            || authcode[1] == \'1\'
            || authcode[1] == \'2\'
            || authcode[1] == \'3\'
            || authcode[1] == \'4\'
            || authcode[1] == \'5\')
        {
            if (validLen == 18)
            {
                return true;
            }
        }
    }
    if (authcode[0] == \'2\')
    {
        //支付宝
        if (authcode[1] == \'5\'
            || authcode[1] == \'6\'
            || authcode[1] == \'7\'
            || authcode[1] == \'8\'
            || authcode[1] == \'9\')
        {
            if (validLen >= 16 && validLen <= 24)
            {
                return true;
            }
        }
    }
    else if (authcode[0] == \'6\')
    {
        //银联二维码
        if (authcode[1] == \'2\')
        {
            if (validLen == 19)
            {
                return true;
            }
        }
    }
    else if (authcode[0] == \'3\' && authcode[1] == \'0\')
    {
        //支付宝
        if (validLen >= 16 && validLen <= 24)
        {
            return true;
        }
    }
    return false;
}

微信:10、11、12、13、14、15开头18位
https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=5_1


支付宝:25、26、27、28、29、30开头长度16-24位
https://blog.csdn.net/Chillax_li/article/details/103271198


银联二维码:62开头19位

 

分类:

技术点:

相关文章: