My site is in asp.net 3.5 and C#. I am sending link to my user through mail, now I want to send each user a specific URL. So instead of sending the clear text I want to send link with encrypted string URL, which I will decrypt on my home page.
Like instead of www.mysite.aspx\mypage?userId=12
I'll send www.mysite.aspx\mypage?UserId=)@kasd12
and the same I'll decrypt on my page so tha开发者_开发知识库t I'll get the userId = 12
.
Please let me know if my approach is correct and not and how can I encrypt & decrypt the string in simplest and easier manner.
isn't it more appropiate to generate a temporary access key?
Generate a random string value instead of encryption/decryption :) And make it at least 6 or 7 characters long. Store the the value in the database and once the value is received through a query string, run a SQL query to do whatever for the corresponding row :)
Page_Load()
string x = Request.QueryString["UserID"];
SqlCommand x = new SqlCommand("UPDATE UserTable SET UserStatus='Activated' WHERE RandomKey='x'", connection);
I'm pretty sure this code project page is what your after. Its basically a HttpModule that can be used to encrypt querystrings.
精彩评论