Request Encryption in C # .net

string emailfield=txtEmail.Text.ToString(); string url = "http://localhost:3076/user/Authenticate-Users.aspx?email="+emailfield; 

I want to encrypt the request and then decrpyt. Is there any way to do this in C #?

thanks

+4
source share
4 answers

You can encrypt the name / value collection into a string, and then just pass that encrypted string as a single request argument.

I demonstrate this technique in the article Encrypting Query Arguments .

+7
source

Since the encrypted data most likely contains special characters, it must be encoded in base64 or similar.

You can find an encoding / decoding class that does the dirty work for you. Many of them are there. Here is one example.

+2
source

Perhaps you are looking for Server.UrlEncode ?

The URLEncode method applies URL encoding rules, including escape characters, to the specified string.

(Just in case, if you were too , with "encrypt", otherwise, others have good answers regarding string value protection.)

0
source

A simpler solution would be to save the GUID along with the user account when creating it. For example, you can name it VerificationCode . When you create a user account, you randomly store a GUID with it, for example, 120a9c10-4f2e-11e0-b8af-0800200c9a66.

Now in the activation link you insert the GUID instead of the email address: http://localhost:3076/user/Authenticate-Users.aspx?code=120a9c10-4f2e-11e0-b8af-0800200c9a66

When the page is executed, it searches for the user by the GUID to indicate that the account has been verified.

0
source

Source: https://habr.com/ru/post/1343820/


All Articles