跳过内容

加密捆绑包

从版本4.15.0开始,插件允许您发送加密更新。

步骤1:创建一个私钥

标题:步骤1:创建一个私钥
生成私钥
npx @capgo/cli key create

步骤 2:创建和压缩您的捆绑包

步骤 2:创建和压缩您的捆绑包
使用校验和创建捆绑包压缩包
npx @capgo/cli bundle zip [appId] --key-v2 --json

这个 --key-v2 旗帜使用新的加密系统,具有更好的校验和,旗帜将输出捆绑包信息,包括您需要的加密的校验和。 --json 步骤 3:加密您的捆绑包

步骤 3:加密您的捆绑包

使用校验和加密捆绑包压缩包
flag uses the new encryption system with better checksums, and the flag will output the bundle information including the checksum that you’ll need for encryption.
npx @capgo/cli encrypt [path/to/zip] [checksum]

Capgo checksum 参数是由第 2 步中的 zip 命令生成的 SHA256 校验和。加密命令将返回一个 ivSessionKey 并生成一个加密的校验和。请记住重命名 ivSessionKey key as session_key 在更新包中。

第四步:在更新包中使用

“步骤 4:在更新包中使用”
{
"version": "1.2.3",
"url": "https://myserver.com/app/updates/my-new-app-2.0.0.zip",
"session_key": "encrypted_session_key",
"checksum": "encrypted_checksum_from_encrypt_command"
}

Capgo session_key 是Capacitor的 ivSessionKey returned by the encrypt command, and the checksum 是加密的校验和在加密过程中生成的(不是 zip 命令中的原始校验和)。

然后您的应用程序将能够使用私钥来解密 session_key 并使用解密的 session_key 来解密更新。加密校验和确保捆绑包完整性验证。