J
Jagadeesh
hi,
here is the block :
public static string Password_Encrypt(String strPassword)
{
Byte[] arrDESKey;
Byte[] arrDESIV;
Byte[] arrInput;
Byte[] arrOutput;
arrDESKey = StringToByte(Promotions.Common.Constants.DESKey);
arrDESIV = StringToByte(Promotions.Common.Constants.DESIV);
// method to convert str to byte
arrInput = StringToByte(strPassword);
arrOutput= StringToByte("");
DESCryptoServiceProvider ObjDES = new DESCryptoServiceProvider();
ICryptoTransform ObjEncryptor = ObjDES.CreateEncryptor(arrDESKey,arrDESIV);
FileStream ObjFileStream = new FileStream(Path.GetTempPath() +
"/secret.txt",FileMode.Create,FileAccess.Write);
CryptoStream ObjCryptoStream = new
CryptoStream(ObjFileStream,ObjEncryptor,CryptoStreamMode.Write);
ObjCryptoStream.Write(arrInput,0,arrInput.Length);
ObjCryptoStream.Close();
FileStream fs = new FileStream(Path.GetTempPath() + "/secret.txt",
FileMode.Open, FileAccess.Read);
arrOutput= new Byte[fs.Length];
fs.Read(arrOutput,0,arrOutput.Length);
fs.Close();
File.Delete(Path.GetTempPath() + "/secret.txt");
Encoding encoding = Encoding.UTF7;
try{
return encoding.GetString(arrOutput);
}
catch
{
return strPassword;
}
}
regards
Jagadeesh
here is the block :
public static string Password_Encrypt(String strPassword)
{
Byte[] arrDESKey;
Byte[] arrDESIV;
Byte[] arrInput;
Byte[] arrOutput;
arrDESKey = StringToByte(Promotions.Common.Constants.DESKey);
arrDESIV = StringToByte(Promotions.Common.Constants.DESIV);
// method to convert str to byte
arrInput = StringToByte(strPassword);
arrOutput= StringToByte("");
DESCryptoServiceProvider ObjDES = new DESCryptoServiceProvider();
ICryptoTransform ObjEncryptor = ObjDES.CreateEncryptor(arrDESKey,arrDESIV);
FileStream ObjFileStream = new FileStream(Path.GetTempPath() +
"/secret.txt",FileMode.Create,FileAccess.Write);
CryptoStream ObjCryptoStream = new
CryptoStream(ObjFileStream,ObjEncryptor,CryptoStreamMode.Write);
ObjCryptoStream.Write(arrInput,0,arrInput.Length);
ObjCryptoStream.Close();
FileStream fs = new FileStream(Path.GetTempPath() + "/secret.txt",
FileMode.Open, FileAccess.Read);
arrOutput= new Byte[fs.Length];
fs.Read(arrOutput,0,arrOutput.Length);
fs.Close();
File.Delete(Path.GetTempPath() + "/secret.txt");
Encoding encoding = Encoding.UTF7;
try{
return encoding.GetString(arrOutput);
}
catch
{
return strPassword;
}
}
regards
Jagadeesh