检查密码的复杂性

至少有小写字母,大写字母,数字,特殊字符

static bool IsLetter(char c)
{
    return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}

static bool IsDigit(char c)
{
    return c >= '0' && c <= '9';
}

static bool IsSymbol(char c)
{
    return c > 32 && c < 127 && !IsDigit(c) && !IsLetter(c);
}

static bool IsValidPassword(string password)
{
    return
       password.Any(c => IsLetter(c)) &&
       password.Any(c => IsDigit(c)) &&
       password.Any(c => IsSymbol(c));
}

  

posted @ 2015-01-22 13:05  lilyfindjob  阅读(184)  评论(0编辑  收藏  举报