public ActionResult <Owner> CreateOwner(Owner owner) { const string allowedChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; Random rng = new Random(); char[] chars = new char[4]; for (int i = 0; i < chars.Length; i++) { chars[i] = allowedChars[rng.Next(0, allowedChars.Length)]; } var salt = new string(chars); var saltedPassword = salt + owner.Password; var bytes = ASCIIEncoding.ASCII.GetBytes(saltedPassword); var hashed = new MD5CryptoServiceProvider().ComputeHash(bytes); owner.Password = ByteArrayToString(hashed); owner.Salt = salt; _networkservice.CreateOwner(owner); return(CreatedAtRoute("GetOwner", new { id = owner.Id.ToString() }, owner)); }