我们有一个使用领域的应用程序版本,但它未加密并且已发布。但现在我们想用最新版本加密领域文件。因此,在 Application 类 onCreate() 中,我调用以下方法。
fun setRealmMigrationConfiguration() {
realmConfiguration = RealmConfiguration.Builder(this)
.schemaVersion(1)
.migration(RealmMigrationClass())
.build()
Realm.setDefaultConfiguration(realmConfiguration)
keyStore.load(null)
val realmKey = "realmKey"
val realmKeyFile = File("${this.filesDir}/$realmKey")
if(keyStore.containsAlias(alias)) {
if(!realmKeyFile.exists()) {
keyStore.deleteEntry(alias)
}
}
val encryptedRealmFileName = "default.realm.enc"
if (!keyStore.containsAlias(alias)) {
//Generates key pair in key store
generateKeyPairInKeyStore(alias)
val privateKeyEntry = keyStore.getEntry(alias, null) as KeyStore.PrivateKeyEntry
val publicKey = privateKeyEntry.certificate.publicKey
val key = generateKey()
val encryptedKey = encryptKey(publicKey,key)
realmKeyFile.writeBytes(encryptedKey)
val unencryptedRealm = File("${this.filesDir}/default.realm")
val encryptedRealm = File("${this.filesDir}/$encryptedRealmFileName")
if (unencryptedRealm.exists() && !encryptedRealm.exists()) {
val realm …Run Code Online (Sandbox Code Playgroud) 我需要安装 Garmin Connect SDK 和 Eclipse 并为 Garmin 产品创建项目。我正在关注
http://developer.garmin.com/connect-iq/getting-started/
我在 Fedora 中执行此操作,因为 Connect IQ SDK 仅适用于 Windows 和 Mac,我正在关注此站点以将其安装在 Fedora 中。根据该网站上的 orx57 评论,我在第二步“chmod +x monkeyc monkeydo”之前执行了 dos2unix ~/connectiq/bin/monkey{c,do} 但在此之后,如果我在控制台中输入monkeyc,它会显示“命令未找到”。如果我在完成上述所有步骤后执行最后一步,则相同。有人可以帮助我解决这个问题吗,或者我可以做些什么来使安装工作?