Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6826971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:12:40+00:00 2026-05-26T22:12:40+00:00

Im practicing with one way hash encryption. I have a MVC model with Entity

  • 0

Im practicing with one way hash encryption.

I have a MVC model with Entity Framework and I wanted to store a password value. I was hoping to have a write only property but what I have found is that if I dont have a return value then it doesn’t get stored in the database. Whenever I visit the edit view I see my hash. I was able to work around that by using an empty generic password input field in the edit view.

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");
            }
        }

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:12:41+00:00Added an answer on May 26, 2026 at 10:12 pm

    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.

    The second property should represent the password plaintext, and should be write-only (and ignored by EF). In its setter, you would hash the password and store it in the other property. Only the code that changes the user’s password should access this method.

    Finally, you should create a Validate() method that accepts the plaintext password, hashes it, and then compares it to the hash property for authentication purposes.

    Using this approach, you can apply validation attributes (regex, for example) to enforce password complexity policy on the plaintext write-only property, for binding in your password editor. You can also use the write-only property to generate password history child records, for enforcing password uniqueness and change frequency policy.

    In addition, you should salt the password hash (I have done this with user GUIDs in the past), so that the same password used by two different users will not have the same hash value. This can be done by concatenating the password plaintext with a unique but deterministic value associated with the user, before hashing it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm practicing writing MVC applications. I have a Mastermind game, that I would like
I am beginner.Practicing in C# 3.0. The requirement is i have to design model
i'm practicing php at nowadays. i have one question. i see one = on
I have been practicing TDD and (some) XP for a few years now and
I have been practicing TDD in C# for several years now and recently have
I've been practicing for an upcoming programming competition and I have stumbled across a
I'm practicing PyQt and (Q)threads by making a simple Twitter client. I have two
I've recently joined TopCoder and have been practicing in the Practice Rooms for the
For practicing purposes, I’m about to create a new ASP.NET MVC 3.0 application. My
I am practicing with PHP and AJAX but I have some problems! I'm trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.