简体   繁体   中英

How to encrypt and decrypt password to store DB in MVC Entity Framework Code First Approach?

How to Encrypt and decrypt Password to store db in MVC Entity Framework? Am using Following Code.Please anyone Help Me.

      [Required]
    [StringLength(15, MinimumLength = 8)]
    [DataType(DataType.Password)]
    [Display(Name = "Password")]
    public string Password { get; set; }

Best practice is not to encrypt/decrypt the password, you should hash it (and salt it)

  • User signs up > hash password > store hash to DB

  • User logs in > hash password > compare to stored hash in DB

This makes the password difficult to recreate if an attacker gets a hold of it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM