Can any one explain this code bolck in detail.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top