Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6002447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:58:46+00:00 2026-05-23T00:58:46+00:00

I want to test if a zip has a particular password in vb.net. How

  • 0

I want to test if a zip has a particular password in vb.net. How can I create a function like check_if_zip_pass(file, pass) As Boolean?

I can’t seem to find anything in the .net framework that does this already, unless I’m missing something incredibly obvious.

This method should NOT extract the files, only return True if the attempted pass is valid and False if not.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:58:47+00:00Added an answer on May 23, 2026 at 12:58 am

    Use a 3rd party library, like DotNetZip. Keep in mind that passwords in zipfiles are applied to entries, not to the entire zip file. So your test doesn’t quite make sense.

    One reason WinZip may refuse to unpack the zipfile is that the very first entry is protected with a password. It could be the case that only some entries are protected by password, and some are not. It could be that different passwords are used on different entries. You’ll have to decide what you want to do about these possibilities.

    One option is to suppose that only one password is used on any entries in the zipfile that are encrypted. (This is not required by the zip specification) In that case, below is some sample code to check the password. There is no way to check a password without doing the decryption. So this code decrypts and extracts into Stream.Null.

    public bool CheckZipPassword(string filename, string password)
    {
        bool success = false;
        try
        {
            using (ZipFile zip1 = ZipFile.Read(filename))
            {
                var bitBucket = System.IO.Stream.Null;
                foreach (var e in zip1)
                {
                    if (!e.IsDirectory && e.UsesEncryption)
                    {
                        e.ExtractWithPassword(bitBucket, password);
                    }
                }
            }
            success = true;    
        }
        catch(Ionic.Zip.BadPasswordException) { }
        return success;
    }
    

    Whoops! I think in C#. In VB.NET this would be:

        Public Function CheckZipPassword(filename As String, password As String) As System.Boolean
            Dim success As System.Boolean = False
            Try
                Using zip1 As ZipFile = ZipFile.Read(filename)
                    Dim bitBucket As System.IO.Stream = System.IO.Stream.Null
                    Dim e As ZipEntry
                    For Each e in zip1
                        If (Not e.IsDirectory) And e.UsesEncryption Then
                            e.ExtractWithPassword(bitBucket, password)
                        End If
                    Next
                 End Using
                 success = True
            Catch ex As Ionic.Zip.BadPasswordException
            End Try
            Return success
        End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like a zip file Test.zip containing 2 folders, say, A and B,
I want to test the behavior of a certain piece of .NET code in
I want to test the web pages I create in all the modern versions
I want to test ASP.NET applications to get the feel for the MVC extension
I want to test ASP.NET application using NUnit, but it seems WebConfigurationManager.ConnectionStrings collection is
I've some test resources (that are specific for a particular task) zipped in /test/resources/my.zip
I want to extract a file from a zip to a specific path, ignoring
I have list of items like this: <ItemGroup> <ToCompile Include=clojure\core.clj;clojure\set.clj;clojure\zip.clj;clojure\test\junit.clj;/> </ItemGroup> And I want
I want to extract some files. Ex. test.zip to /path/to/folder. Using Archive::Extract and specifying
I want to zip a file using bash shell, so I used: echo -n

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.