I use asp.net mvc 5. I have two pages. The first page with a field is to enter the new PIN, the second page is to re-enter the new PIN
I have the url when a submit form in first page to pass the cardID and new PIN, such as:
.../ChangePIN/ConfirmPIN?cardID=123456789&newPIN=123456
and I want to encrypt "cardID = 123456789" and "newPIN = 123456", so how can I do?
namespace ATM.Web.Controllers
{
public class ChangePINController : Controller
{
ATMDb ATMContext = new ATMDb();
string cardID = ATM.Core.Utilities.MyUtilities.getInstance().Card.CardId;
//
// GET: /Card/ChangePIN
public ActionResult ChangePIN(string id)
{
if (id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
var card = ATMContext.Card.Find(id);
if (card == null)
{
return HttpNotFound();
}
ViewBag.cardID = id;
return View();
}
[HttpGet]
public ActionResult ConfirmPIN(string cardID, string newPIN)
{
ViewBag.cardID = cardID;
ViewBag.newPIN = newPIN;
return View();
}
[HttpPost]
public ActionResult ConfirmPIN(string cardID, string newPIN, string newPINConfirm)
{
if (newPIN != newPINConfirm)
{
ViewBag.Message = "";
ViewBag.cardID = cardID;
ViewBag.newPIN = newPIN;
return View();
}
else
{
var card = ATMContext.Card.Find(cardID);
ATMContext.Entry(card).State = EntityState.Modified;
card.PIN = newPINConfirm;
ATMContext.SaveChanges();
return RedirectToAction("Success");
}
}
public ActionResult Success()
{
return View();
}
}
}
Please help me.
Thanks you everyone.
Postfor sensitive information?