0

I have a class with one property and one set-method. password is never serialized to the client but if the client sends in the password it will be serialized and hashed. However i don't like the SetPassword property and would like to user SetPassword(string password) method on object and remove the SetPassword property.

[JsonIgnore]
public byte[] Password { get; set; }

[JsonProperty("password")] // Working but not what i want.
public string SetPassword
{
    set
    {
        Password = new SHA512Managed().ComputeHash(Encoding.UTF8.GetBytes(value + Salt));
    }
}

[???] // What sould i replace ??? with to serialize password from json object?
public void SetPassword(string password)
{
    Password = new SHA512Managed().ComputeHash(Encoding.UTF8.GetBytes(password + Salt));
}
Andreas
  • 6,958
  • 10
  • 38
  • 52

1 Answers1

0

JSON only serializes data (properties), not methods or functions. This is the same for all forms of serializing. How would you know if the machine trying to call SetPassword has a SHA512Managed to call?

prshaw
  • 41
  • 5