C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Encryption »

Decryption of string in C#


Posted Date: 10 Sep 2008    Resource Type: Code Snippets    Category: Encryption
Author: Shivashankar ChincholiMember Level: Gold    
Rating: 1 out of 5Points: 7



//This class is for decrypt the encrypted value
//call this method with two parameters text and key "01AB=$6Q"

class DecryptClass
{

public static string Decrypt(string text, string key)
{

byte[] encodedkey;
byte[] iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
byte[] bytes;

encodedkey = Encoding.UTF8.GetBytes(key);
DESCryptoServiceProvider csp = new DESCryptoServiceProvider();

bytes = Convert.FromBase64String(text);

MemoryStream ms = new MemoryStream();

try
{
CryptoStream cs = new CryptoStream(ms, csp.CreateDecryptor(encodedkey, iv),CryptoStreamMode.Write);
cs.Write(bytes, 0, bytes.Length);
cs.FlushFinalBlock();
}
catch (Exception ex)
{
Logger.LogInfo(ex);
}

return Encoding.UTF8.GetString(ms.ToArray());

}

}



Responses

Author: Amit Srivastava    15 Apr 2009Member Level: Bronze   Points : 1
This code complements the previous encryption code by Shivshankar. All things encrypted, must be decrypted. Here also if some explanation about classes, methods and namespaces is provided i (and other visitors) would have benfitted in a better way by your article sir.


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Decryption  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Decryption of string in VB.Net
Previous Resource: Encryption of string in C#
Return to Discussion Resource Index
Post New Resource
Category: Encryption


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use