两种加密写入文件的写法,先介绍第一种
public class EncryptAndDecryptFile
{
public static string outputFile;
static string password = @"12345678";
//加密
public static void EncryptFile(byte[] fileByte, string name)
{
try
{
UnicodeEncoding UE = new UnicodeEncoding();
byte[] key = UE.GetBytes(password);
//这里调用C#封装好的加密算法
byte[] fileBytes = ByteToString(fileByte, key);
//这里写入二进制文件
if (!System.IO.File.Exists(Application.streamingAssetsPath + "/" + name.Substring(0, name.Length-4)))
{
FileStream nFile = new FileStream(Application.streamingAssetsPath + "/" + name.Substring(0, name.Length - 4), FileMode.Create);
nFile.Write(fileBytes, 0, fileBytes.Length);
nFile.Dispose();
}
}
catch (Exception ex)
{