Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Best way to remove password from archive

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • shaul
    Participant
    Post count: 3
    #44455 |

    Hi,

    What’s the best way to do the following:
    Input: Password protected archive.
    Output: Same archive without a password.

    Thanks,
    Shaul.

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    For security reasons, you cannot remove the password of an encrypted archive and get an output of the same archive without a password. However, if you would like to encrypt an new file without a password, you could remove the DefaultEncryptionPassword property while creating the new archive.

    shaul
    Participant
    Post count: 3

    Thanks for the answer.
    I would like to clarify – I want to do the above while I have the password.

    What I did:

    var inZip = new ZipArchive(fileStream) { DefaultEncryptionPassword = password, DefaultDecryptionPassword = password };

    inZip.CopyFilesTo(outFolder, true, true);

    var localheader = new ZipItemLocalHeader() { EncryptionPassword = null };
    zipWriter.WriteItemLocalHeader(localHeader);
    zipWriter.WriteItemData(fileStream, buffer, 0, buffer.Length);

    Is this what you meant?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.