public ActionResult ReturnBlockChainCalculatedHashNonceAndPrev(BlockChainModel model) { int nonce = 0; string hash = string.Empty; int diffucultLevel = int.Parse(ConfigurationManager.AppSettings["DifficultyLevel"]); var zeros = GetHashRateZeros(diffucultLevel); while (true) { hash = Sha256.CreateSha256(model.Data + model.Prev + nonce); if (hash.Substring(0, diffucultLevel) == zeros) { break; } nonce += 1; } model.Nonce = nonce; model.Hash = hash; return(Json(model, JsonRequestBehavior.AllowGet)); }