Telerik Forums
UI for WPF Forum
1 answer
54 views

I want to encrypt a zip archive.


using (FileStream stream = File.Create(Filepath + Filename))
 {
     DefaultEncryptionSettings encryptionSettings = new DefaultEncryptionSettings();
     encryptionSettings.Password = "123";

     using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Create, false, null, null, encryptionSettings))
     {
          using (ZipArchiveEntry entry = archive.CreateEntry("document.txt"))
          {
               StreamWriter writer = new StreamWriter(entry.Open());
               BinaryFormatter formatter = new BinaryFormatter();
               formatter.Serialize(writer.BaseStream, this);
          }
     }
}
When assigning a string directly for the password, the code works. If I assign the password via a string variable, the zip archive is not encrypted.

Aleks
Telerik team
 answered on 06 Jun 2023
Narrow your results
Selected tags
Tags
+? more
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Patrick
Top achievements
Rank 1
Iron
Iron
Iron
MIS
Top achievements
Rank 1
Ross
Top achievements
Rank 1
Marcin
Top achievements
Rank 1
Iron
Iron
Sean
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?