加密 android 数据库,不工作(显然)
Encrypt android database , dont working (apparently)
我都会process to encrypt database of android:
设置>安全>加密phone
然后我尝试获取 android
的数据库
$ adb shell
$ run-as com.your.package cat /data/data/com.your.package/databases/your_db > /storage/sdcard0/Download/your.db
结果是我所有的数据都没有加密....
我再做一次测试并重新安装我的应用程序,并再次获取我的数据库,所有数据都保持未加密...
我需要做什么来加密我的数据库(无需代码),以及我如何检查加密的数据?
---已编辑---
如果我用这段代码测试加密,我得到 return "true",但我仍然可以访问 .db 并读取所有信息...
@SuppressLint("NewApi")
public static boolean isEncrypted(Context context) {
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context
.getSystemService(Context.DEVICE_POLICY_SERVICE);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
int status = devicePolicyManager.getStorageEncryptionStatus();
if (DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE == status) {
return true;
}
}
return false;
}
Once a device is encrypted, all user-created data is automatically
encrypted before committing it to disk and all reads automatically
decrypt data before returning it to the calling process.
从你提到的文章中你的问题:
So even if someone pulls all the data off your phone, circumventing
the lock screen, the data will be useless without your key.
因此,您的数据在您的 phone 上时会被加密并受到您的锁(例如 PIN 锁)的保护。
当您通过 USB 将设备连接到计算机时,只要您输入了正确的 PIN 码,该操作就被认为是安全的,您的数据将在发送到您的计算机之前被解密。
我都会process to encrypt database of android: 设置>安全>加密phone
然后我尝试获取 android
的数据库$ adb shell
$ run-as com.your.package cat /data/data/com.your.package/databases/your_db > /storage/sdcard0/Download/your.db
结果是我所有的数据都没有加密....
我再做一次测试并重新安装我的应用程序,并再次获取我的数据库,所有数据都保持未加密...
我需要做什么来加密我的数据库(无需代码),以及我如何检查加密的数据?
---已编辑---
如果我用这段代码测试加密,我得到 return "true",但我仍然可以访问 .db 并读取所有信息...
@SuppressLint("NewApi")
public static boolean isEncrypted(Context context) {
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) context
.getSystemService(Context.DEVICE_POLICY_SERVICE);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
int status = devicePolicyManager.getStorageEncryptionStatus();
if (DevicePolicyManager.ENCRYPTION_STATUS_ACTIVE == status) {
return true;
}
}
return false;
}
Once a device is encrypted, all user-created data is automatically encrypted before committing it to disk and all reads automatically decrypt data before returning it to the calling process.
从你提到的文章中你的问题:
So even if someone pulls all the data off your phone, circumventing the lock screen, the data will be useless without your key.
因此,您的数据在您的 phone 上时会被加密并受到您的锁(例如 PIN 锁)的保护。
当您通过 USB 将设备连接到计算机时,只要您输入了正确的 PIN 码,该操作就被认为是安全的,您的数据将在发送到您的计算机之前被解密。