//Đưa SecretKey vào File của thuật toán 3DES
public void AddSecretKeytoFile(string inputFile)
{
//Add SecretKey to File;
if (File.Exists(inputFile))
{
FileStream fsOpen = new FileStream(inputFile, FileMode.Open, FileAccess.ReadWrite);
try
{
byte[] content = new byte[fsOpen.Length];
fsOpen.Read(content, 0, content.Length);
//string sContent = System.Text.Encoding.UTF8.GetString(content); //noi dung bang string
//byte[] plainbytesCheck = System.Text.Encoding.UTF8.GetBytes(sContent);
byte[] plainbytesKey = new UTF8Encoding(true).GetBytes(m_EncryptedSecretKey + "\r\n");
fsOpen.Seek(0, SeekOrigin.Begin);
fsOpen.Write(plainbytesKey, 0, plainbytesKey.Length);
fsOpen.Flush();
fsOpen.Write(content, 0, content.Length);
fsOpen.Flush();
fsOpen.Close();
}
catch
{
fsOpen.Close();
}
}
}