What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 19444 |  Welcome, Guest!   Register  Login
 Home > Forums > ASP.NET > How to encrypt the data ...
Mahesh_Chs

How to encrypt the data

Replies: 2 | Posted by: Mahesh_Chs on 10/31/2012 | Category: ASP.NET Forums | Views: 232 | Status: [Member] | Points: 10  


hi
i have a web page if i run that page and if i check the viewpage source then it is showing complete code, i want to encrypt the code.
how to encrypt the code..


Thank you
Mahesh


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Vasanthmvp
Vasanthmvp  
Posted on: 10/31/2012 8:58:53 AM
Level: Starter | Status: [Member] | Points: 25

Hi Mahesh,
We use html,asp server tags, etc in designing our web page, we include different functionality. A Web Browser converts that code to its own understandable DOM language (html, javascript, jquery, css, etc i.e from server level tags to web tags) which we see when we click on "View Page Source". That means we are actually showing the user only UI part of the page, but not the actual logic code.
I think we can restrict user from viewing this.. But, we have some tags with EnableViewStateProperty, Hidden, etc where we can reduce the data of a control that a page holds. It shows encrypted data here.
Some ways to do is: Disable right click of mouse by including a jquery code with OnMouseDown event or setting OnContentMenu to false.
We also have some software's like firebug to view the page source.
To know more on this, check this link:
http://www.htmlgoodies.com/beyond/article.php/3875651/Web-Developer-Class-How-to-Hide-your-Source-Code.htm
Regards,

Awesome Coding !! :)

Mahesh_Chs, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Vijay.K
Vijay.K  
Posted on: 11/1/2012 2:33:22 AM
Level: Starter | Status: [Member] | Points: 25

public static string EncryptString(string Message, string Passphrase)
{
byte[] Results;
System.Text.UTF8Encoding UTF8 = new System.Text.UTF8Encoding();

// Step 1. We hash the passphrase using MD5
// We use the MD5 hash generator as the result is a 128 bit byte array
// which is a valid length for the TripleDES encoder we use below

MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
byte[] TDESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase));

// Step 2. Create a new TripleDESCryptoServiceProvider object
TripleDESCryptoServiceProvider TDESAlgorithm = new TripleDESCryptoServiceProvider();

// Step 3. Setup the encoder
TDESAlgorithm.Key = TDESKey;
TDESAlgorithm.Mode = CipherMode.ECB;
TDESAlgorithm.Padding = PaddingMode.PKCS7;

// Step 4. Convert the input string to a byte[]
byte[] DataToEncrypt = UTF8.GetBytes(Message);

// Step 5. Attempt to encrypt the string
try
{
ICryptoTransform Encryptor = TDESAlgorithm.CreateEncryptor();
Results = Encryptor.TransformFinalBlock(DataToEncrypt, 0, DataToEncrypt.Length);
}
finally
{
// Clear the TripleDes and Hashprovider services of any sensitive information
TDESAlgorithm.Clear();
HashProvider.Clear();
}

// Step 6. Return the encrypted string as a base64 encoded string
return Convert.ToBase64String(Results);
}


vijay.k

Mahesh_Chs, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 2:30:51 AM