.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Sharon Maxwell

Home >> Forum >> VB.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Encryption and Decryption

Posted By: Abraham     Posted Date: August 23, 2010    Points:2   Category :VB.Net
Encryption and Decryption technique in use of any algorithm using .net programming.

Author: Naim Khan             
Posted Date: August 23, 2010     Points: 5   

hello friend,

Actually i m confused which kind of algorithm you want to Encrypt.. because there are many Algorithm for Encrypt and Decrypt ... well i m sending you one link and i hope it would be help full for you..


Naim Khan

Naim Khan

Software Developer
Author: krishana singh             
Posted Date: October 18, 2010     Points: 5   

public static string Decrypt(string TextToBeDecrypted)

RijndaelManaged RijndaelCipher = new RijndaelManaged();
string Password = "CSC";
string DecryptedData;
byte[] EncryptedData = Convert.FromBase64String(TextToBeDecrypted);

byte[] Salt = Encoding.ASCII.GetBytes(Password.Length.ToString());
//Making of the key for decryption
PasswordDeriveBytes SecretKey = new PasswordDeriveBytes(Password, Salt);
//Creates a symmetric Rijndael decryptor object.
ICryptoTransform Decryptor = RijndaelCipher.CreateDecryptor(SecretKey.GetBytes(32), SecretKey.GetBytes(16));
MemoryStream memoryStream = new MemoryStream(EncryptedData);
//Defines the cryptographics stream for decryption.THe stream contains decrpted data
CryptoStream cryptoStream = new CryptoStream(memoryStream, Decryptor, CryptoStreamMode.Read);
byte[] PlainText = new byte[EncryptedData.Length];
int DecryptedCount = cryptoStream.Read(PlainText, 0, PlainText.Length);
//Converting to string
DecryptedData = Encoding.Unicode.GetString(PlainText, 0, DecryptedCount);
DecryptedData = TextToBeDecrypted;
return DecryptedData;


public static string Encrypt(string TextToBeEncrypted)
RijndaelManaged RijndaelCipher = new RijndaelManaged();
string Password = "CSC";
byte[] PlainText = System.Text.Encoding.Unicode.GetBytes(TextToBeEncrypted);
byte[] Salt = Encoding.ASCII.GetBytes(Password.Length.ToString());
PasswordDeriveBytes SecretKey = new PasswordDeriveBytes(Password, Salt);
//Creates a symmetric encryptor object.
ICryptoTransform Encryptor = RijndaelCipher.CreateEncryptor(SecretKey.GetBytes(32), SecretKey.GetBytes(16));
MemoryStream memoryStream = new MemoryStream();
//Defines a stream that links data streams to cryptographic transformations
CryptoStream cryptoStream = new CryptoStream(memoryStream, Encryptor, CryptoStreamMode.Write);
cryptoStream.Write(PlainText, 0, PlainText.Length);
//Writes the final state and clears the buffer
byte[] CipherBytes = memoryStream.ToArray();
string EncryptedData = Convert.ToBase64String(CipherBytes);
return EncryptedData;


Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend