migrate to new git
This commit is contained in:
50
web/App_Code/security.cs
Normal file
50
web/App_Code/security.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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 "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user