左晓为主开发手持机充值管理机
zuojincheng
2025-03-21 8521954fa97bdfc54123afb4a72755ece311db06
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
package com.dayu.general.tool
 
import android.content.Context
import android.util.Base64
import com.dayu.baselibrary.tools.HexUtil
import com.dayu.baselibrary.tools.nfc.BaseNFCHelper
import java.nio.charset.StandardCharsets
import javax.crypto.Cipher
import javax.crypto.spec.SecretKeySpec
 
open class GeBaseHelper(private val context: Context) : BaseNFCHelper() {
 
 
    companion object {
        init {
            System.loadLibrary("general-native-lib")
        }
    }
 
    private external fun getM1SectorKeySecure(context: Context, sectorIndex: Int): String
 
    init {
        try {
            // 获取所有扇区密钥
            val allKeys: String = getM1SectorKeySecure(context, 0)
            val keys: Array<String> =
                allKeys.split(",").dropLastWhile { it.isEmpty() }.toTypedArray()
            for (i in keys.indices) {
                val key = keys[i]
                listA_PS.add(HexUtil.hexToByteArray(key))
            }
            defauleKey = HexUtil.hexToByteArray("FFFFFFFFFFFF")
 
 
        } catch (e: Exception) {
            e.printStackTrace()
        }
    }
 
    fun getKeyList(): List<ByteArray> {
        return listKeyA
    }
}