package com.dayu.general.tool
|
|
import android.content.Context
|
import com.dayu.baselibrary.tools.HexUtil
|
import com.dayu.baselibrary.tools.nfc.BaseNFCHelper
|
|
open class GeBaseHelper(private val context: Context) : BaseNFCHelper() {
|
|
companion object {
|
init {
|
try {
|
System.loadLibrary("general-native-lib")
|
} catch (e: UnsatisfiedLinkError) {
|
e.printStackTrace()
|
}
|
}
|
}
|
|
private external fun getM1SectorKeySecure(context: Context, sectorIndex: Int): String
|
|
init {
|
try {
|
// 获取所有扇区密钥
|
val allKeys: String = getM1SectorKeySecure(context, 0)
|
if (allKeys.isNotEmpty()) {
|
val keys: Array<String> = allKeys.split(",").dropLastWhile { it.isEmpty() }.toTypedArray()
|
for (i in keys.indices) {
|
val key = keys[i]
|
if (key.isNotEmpty()) {
|
listA_PS.add(HexUtil.hexToByteArray(key))
|
}
|
}
|
}
|
defauleKey = HexUtil.hexToByteArray("FFFFFFFFFFFF")
|
} catch (e: Exception) {
|
e.printStackTrace()
|
// 设置默认密钥
|
defauleKey = HexUtil.hexToByteArray("FFFFFFFFFFFF")
|
}
|
}
|
|
fun getKeyList(): List<ByteArray> {
|
return listKeyA
|
}
|
}
|