如何将通行证(或密钥)写入其他文件而不是编码文件中? C# [英] How to write the pass (or key) in a different file, not on a coding file ? C#
本文介绍了如何将通行证(或密钥)写入其他文件而不是编码文件中? C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public void Encrypt(string SourceFileName, string DestinationFileName, string Key)
{
FileStream FS1 = null, FS2 = null;
try
{
FS1 = new FileStream(SourceFileName, FileMode.Open, FileAccess.Read);
FS2 = new FileStream(DestinationFileName, FileMode.OpenOrCreate);
byte[] input = new byte[FS1.Length];
FS1.Read(input, 0, input.Length);
byte[] Encrypted = Encrypt(input, Key);
FS2.Write(Encrypted, 0, Encrypted.Length);
}
finally
{
FS1.Close();
FS2.Close();
if (Args.stop)
{
File.Delete(DestinationFileName);
}
}
}
推荐答案
您可以将其写在您喜欢的任何位置(例如,参见 ^ ]).但为什么?您是否真的认为外部文件中的密钥不那么容易受到攻击?
You may write it anywhere you like (see, for instance Basic File I/O[^] at MSDN). But, why? Do you really think a key in a external file is less vulnerable?
这篇关于如何将通行证(或密钥)写入其他文件而不是编码文件中? C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文