---
name: "zip_set_default_password"
section: "3"
platform: "linux"
package: "libzip"
version: "1.11.4-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/zip_set_default_password"
---

# zip\_set\_default\_password(3)

set default password for encrypted files in zip

## NAME

**zip\_set\_default\_password** – set default password for encrypted files in zip

## LIBRARY

libzip (-lzip)

## SYNOPSIS

**#include \<zip.h\>**

*int*\

**zip\_set\_default\_password**(*zip\_t \*archive*, *const char \*password*);

## DESCRIPTION

The **zip\_set\_default\_password**() function sets the default password used when accessing encrypted files. If *password* is NULL or the empty string, the default password is unset.

If you prefer a different password for single files, use [zip\_fopen\_encrypted(3)](/zip_fopen_encrypted/3.md) instead of [zip\_fopen(3)](/zip_fopen/3.md). Usually, however, the same password is used for every file in an zip archive.

The password is not verified when calling this function. See the CAVEATS section in [zip\_fopen\_encrypted(3)](/zip_fopen_encrypted/3.md) for more details about password handling.

## RETURN VALUES

Upon successful completion 0 is returned. Otherwise, -1 is returned and the error information in *archive* is set to indicate the error.

## ERRORS

**zip\_set\_default\_password**() fails if:

- \[ZIP\_ER\_MEMORY\]

  Required memory could not be allocated.

## SEE ALSO

[libzip(3)](/libzip/3.md), [zip\_fopen(3)](/zip_fopen/3.md), [zip\_fopen\_encrypted(3)](/zip_fopen_encrypted/3.md)

## HISTORY

**zip\_set\_default\_password**() was added in libzip 0.10.

## AUTHORS

Dieter Baron ⟨*dillo@nih.at*⟩ and Thomas Klausner ⟨*wiz@gatalith.at*⟩
