English 中文(简体)
MVC 密码
原标题:MVC Password Property Hash

采用某种方式进行加密。

我有一个带有实体框架的MVC模式,我希望储存密码价值。 我只想写一份财产,但我发现的是,如果I dont有收益价值,那就没有储存在数据库中。 每当我访问编辑时,我就看到我的过去。 我通过在编辑观点中使用空洞通用密码输入场,能够围绕这一点开展工作。

Now, the problem I now have is if the user wants to edit their information and not change their password (by leaving it blank) it sets the password field to null even though I have not changed the value of that property.

Can anyone suggest a better method? Thanks in advance for your responses.

[DataType(DataType.Password), MaxLength(50)]
    private string _Password;
    public string Password
    {
        get
        {
            return _Password;
        }

        set
        {
            if(!string.IsNullOrEmpty(value))
            {
            _Password = FormsAuthentication.HashPasswordForStoringInConfigFile(value, "MD5");
            }
        }

    }
最佳回答

The best way that I ve found to do this is to create two properties on your entity class. One of those will represent the hashed password, and it will be read/write, so that EF can round-trip it successfully. It is safe to provide the hashed password as read/write, because it is reasonably infeasible to recover the plaintext from the hash.

第二件财产应当代表密码,应当只作文字处理(并且被欧洲法院忽视)。 在座标上,你将翻开密码,将其存放在其他财产中。 只有修改用户密码的代码才能使用这种方法。

最后,您应制定一种认可文字密码的瓦利定(Validate)方法,然后将其与用于认证目的的仓储财产相比较。

采用这种做法,你可以运用验证属性(例如,监管),对纯文字书写的财产执行密码复杂政策,以便在你的密码编辑中具有约束力。 你们还可以使用只字面的财产生成传言历史儿童记录,执行密码独一无二和改变频率政策。

此外,您应打上密码的斜面(我过去曾与使用古董会做过这样的事),这样,两个不同用户使用的相同的密码就不会有同样的印面值。 这样做的方法可以是,在公布密码前,压缩与用户相关的独特但决定性的价值。

问题回答

暂无回答




相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签