我创建了hallo.7z并使用7zxSD_LZMA.sfx作为模块.我认为我的配置是正确的,但在提取sfx时,我收到了
7-zip:不支持的方法
void CreateExeFile()
{
try
{
SfxModule mdl = SfxModule.Extended;
SevenZipSfx sfx = new SevenZipSfx(mdl);
sfx.ModuleFileName = @"7zxSD_LZMA.sfx";
sfx.MakeSfx("D:\\hallo.7z",
new Dictionary<string, string>
{
{ "Title", "Extract Files" },
{ "InstallPath", ProgramFilesx86() + "\\ATIG Platform" },
{ "BeginPrompt", "Choose directory },
{ "CancelPrompt", "Extract Now" },
{ "OverwriteMode", "0" },
{ "GUIMode", "1" },
{ "ExtractDialogText", "Process Extract" },
{ "ExtractTitle", "Extract Files" },
{ "ErrorTitle", "Error" }
},
"D:\\hallo.exe");
MessageBox.Show("Success !");
}
catch (IOException ex) …Run Code Online (Sandbox Code Playgroud) 嘿,我对加密和解密很陌生,说实话,甚至对 C# 语言也很陌生。基本上,我有一个 TCP 聊天服务器,可以“保存”日志并加密文本文件。这就是我加密的方式(基于 MSDN 示例):
public static void EncryptFile(string strInputFileName, string strOutputFileName, string strKey)
{
FileStream fsIn = new FileStream(strInputFileName, FileMode.Open, FileAccess.Read);
FileStream fsOut = new FileStream(strOutputFileName, FileMode.Create, FileAccess.Write);
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
des.Key = ASCIIEncoding.ASCII.GetBytes(strKey);
des.IV = ASCIIEncoding.ASCII.GetBytes(strKey);
ICryptoTransform desencrypt = des.CreateEncryptor();
CryptoStream cryptostream = new CryptoStream(fsOut, desencrypt, CryptoStreamMode.Write);
byte[] byteArrayInput = new byte[fsIn.Length - 1];
fsIn.Read(byteArrayInput, 0, byteArrayInput.Length);
cryptostream.Write(byteArrayInput, 0, byteArrayInput.Length);
fsIn.Close();
fsOut.Close();
}
Run Code Online (Sandbox Code Playgroud)
该方法成功对文件进行完全加密。这是我的解密方法:
public static void DecryptFile(string strInputFileName, string strOutputFileName, string strKey)
{ …Run Code Online (Sandbox Code Playgroud)