Ejemplo n.º 1
0
        public ActionResult GotoPartnerSite(string uid)
        {
            AesCryptography cipher = new AesCryptography();

            string dateTime = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
            byte[] hmac = cipher.Hmac(dateTime, uid);

            UriBuilder target = new UriBuilder("http", "localhost", 65103, "/Home/PartnerSite");
            target.Query = string.Format("i={0}&t={1}&h={2}",
                HttpServerUtility.UrlTokenEncode(cipher.EncryptStringToBytes(uid)),
                HttpServerUtility.UrlTokenEncode(cipher.EncryptStringToBytes(dateTime)), 
                HttpServerUtility.UrlTokenEncode(hmac)
            );

            return Redirect(target.Uri.AbsoluteUri);
        }
Ejemplo n.º 2
0
 //uid 암호화
 public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
 {
     //Get uid from route data
     string uid = values["uid"] == null ? string.Empty : values["uid"].ToString();
     if(!string.IsNullOrWhiteSpace(uid))
     {
         //Encrypt and url encode uid
         AesCryptography helper = new AesCryptography();
         byte[] encryptedId = helper.EncryptStringToBytes(uid);
         values["uid"] = HttpServerUtility.UrlTokenEncode(encryptedId); 
     }
     return base.GetVirtualPath(requestContext, values);
 }