DefaultEncryptionSettings

1 Answer 60 Views
General Discussions Security
Harald
Top achievements
Rank 2
Harald asked on 05 Jun 2023, 11:40 AM

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.

Harald
Top achievements
Rank 2
commented on 05 Jun 2023, 12:21 PM | edited

Now it seems to work. No idea why.

1 Answer, 1 is accepted

Sort by
0
Accepted
Aleks
Telerik team
answered on 06 Jun 2023, 04:51 AM

Hello Harald,

Thank you for contacting us.

I tried reproducing your case but I did not stumble across the same scenario as you have given. Could you please let me know if I am missing something?

Please find the attached file and update it so the issue reproduces. If you have any other questions, please add them as well.

Regards,
Aleks
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Harald
Top achievements
Rank 2
commented on 06 Jun 2023, 06:38 PM

Thank you for the feedback. Apparently it was my mistake. It works fine now.
Aleks
Telerik team
commented on 07 Jun 2023, 07:04 AM

Hi Harald,

I am happy to hear that.

Should you need any further assistance, please do not hesitate to contact us.

Regards,
Aleks
Progress Telerik

Tags
General Discussions Security
Asked by
Harald
Top achievements
Rank 2
Answers by
Aleks
Telerik team
Share this question
or