APK
Android install file
A ZIP archive with compiled code, resources and assets. Android installs it directly on a device. Web files usually sit in the assets folder, where they can be read.
An APK, AAB or IPA is a ZIP archive. Anyone can rename it, unzip it and copy your HTML, JavaScript, images and audio. html2app encrypts each file at build time, and the app's local server decrypts a file only when the web view requests it.
An app package is a container. Open it and you find the files your build produced, with the same names and the same contents.
Android install file
A ZIP archive with compiled code, resources and assets. Android installs it directly on a device. Web files usually sit in the assets folder, where they can be read.
Android App Bundle
The publishing format for Google Play. It is a ZIP-based archive too. Google Play generates device-specific APKs from it, and devices cannot install the bundle itself.
iOS app package
A ZIP archive with a Payload folder that holds the app bundle: the binary, resources and your web files.
Cordova, Capacitor and most web-to-app builders copy the compiled web folder into the native project. The web view then loads those files from inside the app. Core versions of these tools do not encrypt the files, so each one stays readable after unzipping.
The web files go into the package unchanged.
Each file is encrypted before it goes into the package.
The comparison covers the common default setup of each tool.
| Question | Typical wrapper or builder | html2app (preview) |
|---|---|---|
| Readable after unzipping the package | Yes. HTML, CSS, JavaScript, images and audio stay as they are. | No. Each file is stored as ciphertext. |
| Encryption at build time | Not in the core of Capacitor or Cordova. | Yes, for every file in the build. |
| Decryption | Not needed. | Per request, by the local server middleware, in memory only. |
| Encryption add-ons | Some exist. Their maintenance varies a lot. | Built in. No plugin to install. |
If you use an add-on for Cordova or Capacitor, check its last release, platform support and open issues before you rely on it.
The package never holds readable copies of your files. The local server opens one file at a time, when the web view asks for it.
script.js.crypt
Every file in the web build is encrypted with AES-256-GCM. The output holds a 12-byte nonce, the ciphertext and a 16-byte authentication tag.
script.js becomes script.js.crypt. The extension tells the server which
files to decrypt.
The APK, AAB or IPA carries the .crypt files. No readable copy goes into the package.
The web view requests a file. The local server finds the encrypted version in the package.
The middleware decrypts the requested file. Files nobody requests are never decrypted.
The content goes out with the MIME type of the original file name. The middleware does not write it to disk.
final handler = const Pipeline()
.addMiddleware(decryptionMiddleware(
decryptHandler: decryptAsset,
encryptedExtensions: ['.crypt', '.enc', '.encrypted'],
))
.addHandler(assetHandler);
The middleware sits between the file server and the response. Only requests for an encrypted extension reach the decrypt step.
// Layout per file: [12-byte nonce][ciphertext][16-byte tag]
Future<List<int>> decryptAsset(String path, List<int> encryptedBytes) async {
if (encryptedBytes.length < 28) {
throw FormatException('Encrypted file too short');
}
final data = Uint8List.fromList(encryptedBytes);
final nonce = data.sublist(0, 12);
final cipherText = data.sublist(12, data.length - 16);
final tag = Mac(data.sublist(data.length - 16));
// Key source is an open design question, see Limits. The app needs it at runtime.
final key = await appKey();
// AES-GCM checks the tag first. A changed file throws instead of returning bytes.
return AesGcm.with256bits().decrypt(
SecretBox(cipherText, nonce: nonce, mac: tag),
secretKey: key,
);
}
A sketch based on the decryption example in the middleware documentation, not the production code.
Pick a file, then switch between a typical wrapper package and an html2app package. The previews show what anyone sees after unzipping.
<!doctype html>
<html lang="en">
<script src="js/app.js"></script>
</html>
Ciphertext. Nonce, encrypted bytes and tag.
3a 9f c2 61 0e b7 4d 82 f1 5c 08 ae 2d 77 1b c4
e0 58 13 9d 6a f2 44 0b c7 91 2e 85 d3 0f a6 17
const score = 0;
console.log('Hello from app.js');
Ciphertext. Nonce, encrypted bytes and tag.
7c 1e a0 39 d4 8b 52 f6 0a c3 91 4e 2b d8 67 f0
5d a2 0e 74 b9 3c 88 1f e6 47 d0 29 9b 4a c5 12
Opens in any image viewer. The file starts with the PNG signature:
89 50 4e 47 0d 0a 1a 0a ...
Ciphertext. Nonce, encrypted bytes and tag.
b4 0c 9e f3 27 d1 6a 88 4f 0b e2 7d 19 c6 a3 5e
8f 31 d0 6b 2c 97 e4 05 aa 6d 13 c8 f9 42 0e 7b
Playable in any media player. Copy the file and press play.
Ciphertext. Nonce, encrypted bytes and tag.
e9 17 b3 5a 80 cc 2f 64 d1 0e 9a 33 f7 4c b8 26
1d 6e a0 c9 52 ff 3b 87 e4 18 7a d6 0c 91 5b 2e
Illustration with placeholder data. The byte values are examples, not output from a build.
Encryption raises the effort needed to copy your assets. It does not make the app secret. Know these limits before you rely on it.
Treat encryption as one layer. Keep sensitive logic and secrets on a server you control.
No. This page describes a feature that is not published yet. Details may change before release.
Every file in the web build, including HTML, CSS, JavaScript, images, audio and video. Each encrypted
file keeps its original name and adds an encrypted extension such as .crypt.
Decryption fails. AES-GCM checks the authentication tag before it returns any bytes, so the local server returns an error instead of the modified content.
No. The decryption middleware returns the bytes in memory for the response. It does not write them to disk.
You can, if it fits your setup. Check the plugin's last release, platform support and open issues first, because add-on maintenance varies a lot.
Encrypted assets are in preview. Build on html2app.dev now, and read the developer app guide in the meantime.