React Native Requires Chilkat v11.0.0+
React Native
Create Password Protected Zip containing a Single File.
See more Zip Examples
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.)Chilkat React Native Downloads
import { Zip } from '@chilkat/react-native'
async function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const zip = new Zip();
try {
zip.newZip('test.zip');
} catch {
console.log(zip.lastErrorText);
return;
}
zip.setPassword('secret');
zip.passwordProtect = true;
const saveExtraPath = false;
zip.addFile('/temp/hamlet.xml', saveExtraPath);
try {
await zip.writeZipAndCloseAsync();
} catch {
console.log(zip.lastErrorText);
return;
}
console.log('Zip Created!');
}