ZIP_FILE_SET_ENCRYPTION(3)

πŸ“¦
version 1.11.4 Β· 3 versions
, in arch rolling, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– 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] β€” index is not a valid file index in archive, 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 πŸ’–πŸ¦‹πŸŒΈ