左晓为主开发手持机充值管理机
zuojincheng
2025-03-26 1bc1acff2127d61b359800096ad5b904370d9176
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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
    }
}