ZIP_FILE_SET_ENCRYPTION(3)
π ZIP_FILE_SET_ENCRYPTION(3) π
okay bestie, welcome to the Library Functions Manual page for zip_file_set_encryption β yes it's a long name, yes it's giving "I took a whole paragraph just to say my name," but she's worth it π
β¨ NAME β¨
zip_file_set_encryption β set encryption method for file in zip
π LIBRARY π
libzip (-lzip) β that's the girl. Link her in and we're good π
πΈ SYNOPSIS πΈ
#include <zip.h>
int
zip_file_set_encryption(zip_t *archive, zip_uint64_t index,
zip_uint16_t method, const char *password);
π¦ DESCRIPTION π¦
So like, the whole vibe of zip_file_set_encryption() is: you've got a file sitting at position index inside the zip archive, and you're like "hmm, this needs a lock on it π" β and this function right here sets the encryption method for that file, using the password you hand it. That's the whole assignment, and she ate.
The method is literally the same thing that zip_stat(3) returns, so if you've been stat-ing around, you already know her.
For the method argument, currently only these values are supported β no more, no less, don't try to freestyle:
ZIP_EM_NONEβ no encryption at all. She's an open book πZIP_EM_AES_128β Winzip AES-128 encryption.ZIP_EM_AES_192β Winzip AES-192 encryption.ZIP_EM_AES_256β Winzip AES-256 encryption.ZIP_EM_TRAD_PKWAREβ Traditional PKWare encryption.
NOT ME telling you this but: do not use ZIP_EM_TRAD_PKWARE, it is not secure. π© It's only provided for backwards compatibility. Like, she's still on the guest list but everyone knows why.
If password is NULL, then the default password β the one you set with zip_set_default_password(3) β gets used instead. Convenient β¨
And if you ever wanna know what encryption method a file in a zip archive is currently rocking, you can just determine that with zip_stat(3). Vibe check via stat, love that for us.
π«Ά RETURN VALUES π«Ά
Upon successful completion, 0 is returned. Iconic. Perfect. No notes.
Otherwise, -1 is returned and the error information in archive is set to indicate the error. Not the slay we wanted π but at least she tells you why.
π ERRORS π
zip_file_set_encryption() fails if:
[ZIP_ER_ENCRNOTSUPP]β Unsupported compression method requested.[ZIP_ER_INVAL]βindexis not a valid file index inarchive, or the argument combination is invalid.[ZIP_ER_MEMORY]β Required memory could not be allocated. She's out of room, bestie π₯²[ZIP_ER_RDONLY]β Read-only zip file, no changes allowed. Hands off, she's not taking edits π
π SEE ALSO π
libzip(3), zip_encryption_method_supported(3), zip_fopen_encrypted(3), zip_fopen_index_encrypted(3), zip_set_default_password(3), zip_stat(3)
π HISTORY π
zip_file_set_encryption() was added in libzip 1.2.0. She's been around a minute, iykyk π
π AUTHORS π
Dieter Baron <dillo@nih.at> and Thomas Klausner <wiz@gatalith.at> β the two icons who wrote this whole thing, we thank them for their service π«‘β¨
and that's the page, bestie!! π this one came from Debian, dated April 2, 2020, and it's your girl ZIP_FILE_SET_ENCRYPTION(3) signing off β stay encrypted, stay iconic, periodt ππ¦πΈ
π¦ where this page comes from
- arch rolling: libzip 1.11.4-1 Β· BSD
- debian trixie: libzip-dev 1.11.3-2 Β· BSD-3-Clause
- fedora 43: libzip-devel 1.11.4-2.fc43 Β· BSD-3-Clause
- fedora 43: libzip-devel 1.11.4-2.fc43 Β· BSD-3-Clause
- fedora 44: libzip-devel 1.11.4-3.fc44 Β· BSD-3-Clause
- fedora 44: libzip-devel 1.11.4-3.fc44 Β· BSD-3-Clause
- nixpkgs unstable: libzip 1.11.4
- ubuntu questing: libzip-dev 1.11.3-2
- ubuntu resolute: libzip-dev 1.11.4-2 Β· BSD-3-Clause
- ubuntu stonking: libzip-dev 1.11.4-2build1 Β· BSD-3-Clause
- Copyright (C) 2016-2021 Dieter Baron and Thomas Klausner
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms