-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: diniya25
Message 2 in Discussion

Hi I have given the code here    Decryption.cs    
using System; 
using System.Security.Cryptography; 
using System.IO; 
namespace SFTPCrypt 
{ 
/// <summary> 
/// Summary description for Decryption. 
/// </summary> 
public class Decryption 
{ 
public Decryption() 
{ 
// 
// TODO: Add constructor logic here 
// 
} 
private static byte[] Decrypt(byte[] cipherData, byte[] Key, byte[] IV)  
{  
// Create a MemoryStream that is going to accept the decrypted bytes  
MemoryStream ms = new MemoryStream();  
Rijndael alg = Rijndael.Create();  
  
alg.Key = Key;  
alg.IV = IV;  
CryptoStream cs = new CryptoStream(ms, alg.CreateDecryptor(), 
CryptoStreamMode.Write);  
// Write the data and make it do the decryption  
cs.Write(cipherData, 0, cipherData.Length);  
 
cs.Close();  
byte[] decryptedData = ms.ToArray();  
 
return decryptedData;  
}  
 
 
// Decrypt a string into a string using a password  
// Uses Decrypt(byte[], byte[], byte[])  
public static string Decrypt(string cipherText, string Password)  
{  
byte[] cipherBytes = Convert.FromBase64String(cipherText);  
 
PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password,  
new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 
0x65, 0x76});  
byte[] decryptedData = Decrypt(cipherBytes, pdb.GetBytes(32), 
pdb.GetBytes(16));  
 
return System.Text.Encoding.Unicode.GetString(decryptedData);  
 
}  
 
 
// Decrypt bytes into bytes using a password  
// Uses Decrypt(byte[], byte[], byte[])  
private static byte[] Decrypt(byte[] cipherData, string Password)  
{  
PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password,  
new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 
0x65, 0x76});  
return Decrypt(cipherData, pdb.GetBytes(32), pdb.GetBytes(16));  
 
}  
} 
} 
  
Encryption.cs 
using System; 
using System.Security.Cryptography; 
using System.IO; 
namespace SFTPCrypt 
{ 
/// <summary> 
/// Summary description for Encryption. 
/// </summary> 
public class Encryption 
{ 
public Encryption() 
{ 
// 
// TODO: Add constructor logic here 
// 
} 
public static string Encrypt(string clearText, string Password)  
{  
byte[] clearBytes = System.Text.Encoding.Unicode.GetBytes(clearText);  
 
PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password,  
new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 
0x65, 0x76});  
byte[] encryptedData = Encrypt(clearBytes, pdb.GetBytes(32), pdb.GetBytes(16)); 
 
 
return Convert.ToBase64String(encryptedData);  
 
}  
 
private static byte[] Encrypt(byte[] clearData, string Password)  
{  
PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password,  
new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 
0x65, 0x76});  
return Encrypt(clearData, pdb.GetBytes(32), pdb.GetBytes(16));  
}  
  
private static byte[] Encrypt(byte[] clearData, byte[] Key, byte[] IV)  
{  
MemoryStream ms = new MemoryStream();  
Rijndael alg = Rijndael.Create();  
alg.Key = Key;  
alg.IV = IV;  
CryptoStream cs = new CryptoStream(ms, alg.CreateEncryptor(), 
CryptoStreamMode.Write);  
cs.Write(clearData, 0, clearData.Length);  
cs.Close();  
byte[] encryptedData = ms.ToArray();  
return encryptedData;  
}  
} 
} 
I hope this will be usefull for u. 
Otheriwse give me a call 9845908676 
Thanx 
  
  
  
 

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to