Files
17168ERP/web/App_Code/security.cs
2025-08-29 01:27:25 +08:00

51 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Data.OleDb;
using System.Collections;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MyWeb
{
public class security
{
public string pwStrength { get; set; }
public security()
{
pwStrength = ConfigurationManager.AppSettings["pwStrength"].ToString();
}
public string PasswordValidator()
{
switch (pwStrength) {
case "1":
return "^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{6,}$";
case "2":
return "^(?!.*(.)\\1)(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{6,}$";
case "3":
return "^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[#?!@$%~^&*+-]).{12,}$";
default:
return "";
}
}
public string PasswordNotice()
{
switch (pwStrength) {
case "1":
return "密碼長度必需至少6位數至少需包含數字、英文大小寫";
case "2":
return "密碼長度必需至少6個字元且至少需包含數字、英文大小寫不得有2個以上的連續字元";
case "3":
return "密碼長度必需至少12個字元且至少需包含數字、字符(如:!@#$%)、英文大小寫";
default:
return "";
}
}
}
}