(Swift) Create Password Protected Zip containing a Single File.
Create a password-protected .zip containing a single file. (This uses the older Zip 2.0 encryption scheme, which is weaker and not as secure as AES encryption, which Chilkat Zip also supports.)
func chilkatTest() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let zip = CkoZip()!
var success: Bool = zip.newZip("test.zip")
if success != true {
print("\(zip.lastErrorText!)")
return
}
zip.setPassword("secret")
zip.passwordProtect = true
var saveExtraPath: Bool
saveExtraPath = false
success = zip.appendOneFileOrDir("/temp/hamlet.xml", saveExtraPath: saveExtraPath)
var success: Bool = zip.writeAndClose()
if success != true {
print("\(zip.lastErrorText!)")
return
}
print("Zip Created!")
}
|