Sample code for 30+ languages & platforms
Dart

Verify a Zip's Password

See more Zip Examples

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

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

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

  final zip = CkZip();

  // To verify a password for a Zip, the Zip must be opened:
  try {
    zip.openZip('myProtected.zip');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

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

  final passwordOk = zip.verifyPassword();
  if (passwordOk) {
    print('Password is correct.');
  } else {
    print('Password is incorrect.');
  }

  zip.closeZip();
}