本文介绍了如何验证密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友,
我有一个自动生成密码的任务,在这种情况下,我使用日期,时间和天数.但是一个条件是,密码在该天有效,并且超过该天后,该应用程序不会自动运行.


字符串pwd,noofdays;
noofdays = textBox2.Text;
pwd = DateTime.Now.ToString("yyyyMMdd1221" +"+" + noofdays);
textBox3.Text = pwd;

HI friends,
i have a task that is automatically generate a password in this case i use date,time and no of days.But one condition is there the password is valid for that days and greater than that days the application is run not automatically.


String pwd, noofdays;
noofdays = textBox2.Text;
pwd = DateTime.Now.ToString("yyyyMMdd1221" + "+" + noofdays);
textBox3.Text = pwd;

推荐答案


public string GeneratePassword(string userName)
{
    if (string.IsNullOrEmpty(userName))
        return "NAN";

    userName = userName.ToUpper();

    return string.Format("{0}{1}{2}{3}", "8080110001",EncryptedUserName(userName), userName, DateTime.Now);
}

public int EncryptedUserName(string userName)
{
    int partOfSecurity = 0;
    foreach (char c in userName)
    {
        partOfSecurity += (int)c;
    }
    return partOfSecurity;
}
public bool IsAuthenticated(string userName, string passWord)
{
    if (string.IsNullOrEmpty(userName) || passWord.Length <10)
        return false;
     userName = userName.ToUpper();



     return
         (passWord.Substring(0, 10) == "8080110001" && passWord.Replace(EncryptedUserName(userName).ToString(), string.Empty) != passWord && passWord.Replace(userName, string.Empty) != passWord)
         ? true : false;
}




但是,我强调它的安全性很差.




But, I emphasize that it''s a poor security.



这篇关于如何验证密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 05:57