Xamarin Forms "Bundle assemblies into native code" 和 ofbuscation

Xamarin Forms "Bundle assemblies into native code" and ofbuscation

我使用 Xamarin Forms 创建了 Android 应用程序。对于发布,我使用选项 "Bundle assemblies into native code"。 我的 apk 有大小 - 17 Mb,没有这个选项 33 Mb。我是否需要对我的库使用混淆或我的代码受到保护? 我搜索了很多 - 但我没有找到确切的答案。

Bundle Assemblies into Native Code 表示:

When this option is enabled, assemblies are bundled into a native shared library. This option keeps your code safe; it protects managed assemblies by embedding them in native binaries.

保持安全 :

这些会将 .dll 文件捆绑到一个 .so 文件中,这样它们就更难在 root 设备上被篡改了。正如 BobFlora 所说:它会将 IL 代码与本机二进制文件(.so 文件)一起移动,因此黑客更难搞砸它。这里没有性能问题。

减小 apk 大小 :

此选项将显着减小 apk 大小,因为 .so 文件被压缩而 dlls 没有。

我创建了一个空项目,我们可以发现使用此选项时的不同之处:

  • 没有使用 Bundle Assemblies into Native Code :

  • 使用Bundle Assemblies into Native Code

Do I need to use obfuscation for my libraries or my code is protected?

它有助于增加代码混淆(特别是在 Android 上),还有其他方法可以增加 security/cryptography。如果您有更严格的安全要求,您可以使用此选项,这取决于您的要求。