Sample code for 30+ languages & platforms
React Native

Verify a Zip's Password

See more Zip Examples

Demonstrates how to verify the password for an encrypted or password-protected zip archive.

Chilkat React Native Downloads

React Native
import { Zip } from '@chilkat/react-native'

async function chilkatExample() {
  // This example requires the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  const zip = new Zip();

  // To verify a password for a Zip, the Zip must be opened:
  try {
    await zip.openZipAsync('myProtected.zip');
  } catch {
    console.log(zip.lastErrorText);
    return;
  }

  // Set the password to be verified:
  zip.decryptPassword = 'secret';

  const passwordOk = zip.verifyPassword();
  if (passwordOk) {
    console.log('Password is correct.');
  } else {
    console.log('Password is incorrect.');
  }

  zip.closeZip();
}