Query string encryption decryption technique

Encryption Technique
String Id = dtResult.Rows[0][0].ToString();
String dbPassValue = dtResult.Rows[0][2].ToString();
Boolean isPasswordMatched = LoginPassword.Equals(dbPassValue, StringComparison.Ordinal);

if (isPasswordMatched)
{
       String eid = MyCrypto.GetEncryptedQueryString(UserId); //encrypted id
       return Json(new { result = “Redirect”, url = “/Dsr/Home/Index?id=” + Id + “&eid=” + eid });
}

Decryption Technique
if (Request.QueryString[“id”] == null || Request.QueryString[“eid”] == null)
{
      return RedirectToAction(“Index”, “LogIn”, new { area = “Dsr” });
}

String UserId = Request.QueryString[“userid”].ToString();
String encryptedUserId = Request.QueryString[“eid”].ToString();
String userDigest = MyCrypto.GetDecryptedQueryString(encryptedUserId);

            if (!UserId.Equals(userDigest, StringComparison.Ordinal))
            {
                return RedirectToAction(“Index”, “LogIn”, new { area = “Dsr” });
            }


            ViewBag.UserId = UserId; ViewBag.UserIdDigest = encryptedUserIdDigest;
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s