狠狠色丁香婷婷综合尤物/久久精品综合一区二区三区/中国有色金属学报/国产日韩欧美在线观看 - 国产一区二区三区四区五区tv

LOGO OA教程 ERP教程 模切知識交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

C#檢測密碼強度,評分規(guī)則仿google

freeflydom
2025年5月17日 9:54 本文熱度 981

參考delphi的代碼更改為C#

Delphi 檢測密碼強度 規(guī)則(仿 google)

仿 google 評分規(guī)則

一、密碼長度:

5 分: 小于等于 4 個字符
10 分: 5 到 7 字符
25 分: 大于等于 8 個字符

二、字母:

0 分: 沒有字母
10 分: 全都是小(大)寫字母
20 分: 大小寫混合字母

三、數(shù)字:

0 分: 沒有數(shù)字
10 分: 1 個數(shù)字
20 分: 大于等于 3 個數(shù)字

四、符號:

0 分: 沒有符號
10 分: 1 個符號
25 分: 大于 1 個符號

五、獎勵:

2 分: 字母和數(shù)字
3 分: 字母、數(shù)字和符號
5 分: 大小寫字母、數(shù)字和符號

最后的評分標準:

>= 90: 非常安全
>= 80: 安全(Secure)
>= 70: 非常強
>= 60: 強(Strong)
>= 50: 一般(Average)
>= 25: 弱(Weak)
>= 0: 非常弱

代碼如下

    /// <summary>
    /// 得到強度的文本描述
    /// </summary>
    /// <param name="password"></param>
    /// <returns></returns>
    public static string GetkPasswordStrong(string password)
    {
        int strong=CheckPasswordStrong(password);
        if (strong >= 90)
            return $"非常安全{strong}";
        else if (strong >= 80)
            return $"安全{strong}";
        else if (strong >= 70)
            return $"非常強{strong}";
        else if (strong >= 60)
            return $"強{strong}";
        else if (strong >= 50)
            return $"一般{strong}";
        else if (strong >= 25)
            return $"弱{strong}";
        else
            return $"非常弱{strong}";
    }
    /// <summary>
    /// 檢測密碼強度,規(guī)則(仿 google)
    /// 
    ///= 90: 非常安全
    ///>= 80: 安全(Secure)
    ///>= 70: 非常強
    ///>= 60: 強(Strong)
    ///>= 50: 一般(Average)
    ///>= 25: 弱(Weak)
    ///>= 0: 非常弱
    /// </summary>
    /// <param name="password"></param>
    /// <returns></returns>
    public static int CheckPasswordStrong(string password)  //檢測密碼強度  規(guī)則(仿 google)
    {
        int Result = 0;
        int i, countLowercase, countUppercase, countDigit, countSymbol;
        int iLen=password.Length;
        if (iLen <= 4)
            Result = 5;
        else if (iLen >= 5 && iLen <= 7)
            Result = 10;
        else if (iLen >= 8)
            Result = 25;
        countLowercase = 0;
        countUppercase = 0;
        countDigit = 0;
        countSymbol = 0;
        for (i = 0; i < iLen;i++)
        {
            char c= password[i];
            if (c >= '0' && c <= '9')
                countDigit++;
            else if (c >= 'a' && c <= 'z')
                countLowercase++;
            else if (c >= 'A' && c <= 'Z')
                countUppercase++;
            else
                countSymbol++;
        }
        //大小寫
        //0 分: 沒有字母
        //10 分: 全都是小(大)寫字母
        //20 分: 大小寫混合字母
        if (countLowercase == 0 && countUppercase == 0)
            Result = Result + 0;
        else if ((countLowercase == 0 && countUppercase > 0) || (countLowercase > 0 && countUppercase == 0))
            Result = Result + 10;
        else if (countLowercase >0 && countUppercase > 0)
            Result = Result + 20;
        // 計算數(shù)字得分
        if (countDigit == 0)
            Result = Result + 0;
        else if (countDigit == 1)
            Result = Result + 10;
        else if (countDigit >= 3)
            Result = Result + 20;
        //符號評分
        if (countSymbol == 0)
            Result = Result + 0;
        else if (countSymbol == 1)
            Result = Result + 10;
        else if (countSymbol > 1)
            Result = Result + 25;
        //五、獎勵:
        //2 分: 字母和數(shù)字
        //3 分: 字母、數(shù)字和符號
        //5 分: 大小寫字母、數(shù)字和符號
        if ((countLowercase > 0) && (countUppercase > 0) && (countDigit > 0) && (countSymbol == 0))
            Result = Result + 2;
        else if ((countLowercase > 0) && (countUppercase > 0) && (countDigit > 0) && (countSymbol > 0))
            Result = Result + 5;
       else if (((countLowercase > 0) || (countUppercase > 0)) & (countDigit > 0) && (countSymbol > 0))
            Result = Result + 3;
        return Result;
    }

轉自https://www.cnblogs.com/james-yu/p/18251480


該文章在 2025/5/17 9:55:31 編輯過
關鍵字查詢
相關文章
正在查詢...
點晴ERP是一款針對中小制造業(yè)的專業(yè)生產管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內大量中小企業(yè)的青睞。
點晴PMS碼頭管理系統(tǒng)主要針對港口碼頭集裝箱與散貨日常運作、調度、堆場、車隊、財務費用、相關報表等業(yè)務管理,結合碼頭的業(yè)務特點,圍繞調度、堆場作業(yè)而開發(fā)的。集技術的先進性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點晴WMS倉儲管理系統(tǒng)提供了貨物產品管理,銷售管理,采購管理,倉儲管理,倉庫管理,保質期管理,貨位管理,庫位管理,生產管理,WMS管理系統(tǒng),標簽打印,條形碼,二維碼管理,批號管理軟件。
點晴免費OA是一款軟件和通用服務都免費,不限功能、不限時間、不限用戶的免費OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved