Merge branch 'master' of gitlab.navinfo.com:CollectVehicle/OneMapQS
Conflicts: app/src/main/java/com/navinfo/omqs/OMQSApplication.kt
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
package com.navinfo.omqs
|
||||
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import com.navinfo.omqs.tools.FileManager
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import io.realm.Realm
|
||||
import io.realm.RealmConfiguration
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.File
|
||||
import java.math.BigInteger
|
||||
import java.security.MessageDigest
|
||||
|
||||
@HiltAndroidApp
|
||||
class OMQSApplication : Application() {
|
||||
@@ -13,16 +17,26 @@ class OMQSApplication : Application() {
|
||||
super.onCreate()
|
||||
FileManager.initRootDir(this)
|
||||
Realm.init(this)
|
||||
val password = "password".encodeToByteArray().copyInto(ByteArray(64))
|
||||
// 1110000011000010111001101110011011101110110111101110010011001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
// Log.d("", "密码是: ${BigInteger(1, password).toString(2).padStart(64, '0')}")
|
||||
val password = "encryp".encodeToByteArray().copyInto(ByteArray(64))
|
||||
// 70617373776f72640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
|
||||
Log.d("OMQSApplication", "密码是: ${byteArrayToHexString(password)}")
|
||||
val config = RealmConfiguration.Builder()
|
||||
.directory(File(Constant.DATA_PATH))
|
||||
.name("HDData")
|
||||
.name("OMQS.realm")
|
||||
.encryptionKey(password)
|
||||
// .modules(Realm.getDefaultModule(), MyRealmModule())
|
||||
.schemaVersion(1)
|
||||
// .encryptionKey(password)
|
||||
.build()
|
||||
Realm.setDefaultConfiguration(config)
|
||||
}
|
||||
|
||||
private fun getKey(inputString: String): String {
|
||||
val messageDigest = MessageDigest.getInstance("SHA-256")
|
||||
val hashBytes = messageDigest.digest(inputString.toByteArray())
|
||||
return hashBytes.joinToString("") { "%02x".format(it) };
|
||||
}
|
||||
|
||||
fun byteArrayToHexString(byteArray: ByteArray): String {
|
||||
return byteArray.joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user