package com.seewo.libnfc.customer;

import android.text.TextUtils;
import android.util.Log;
import com.seewo.libnfc.cipher.AESTool;
import com.seewo.libnfc.customer.NfcData;
import com.seewo.libnfc.tools.HexTools;

/* JADX INFO: loaded from: classes.dex */
public class SaharaData extends NfcData {
    private static final String TAG = "SaharaData";
    private String mData;
    private String mUserKey;
    private String mUserPs;

    public SaharaData(String str, String str2) {
        this.mUserPs = str;
        this.mUserKey = str2;
    }

    public SaharaData(String str) {
        this.mData = str;
    }

    public SaharaData(byte[] bArr, String str) {
        String strDecryptWithRandomKey;
        if (bArr == null || bArr.length == 0) {
            return;
        }
        try {
            strDecryptWithRandomKey = AESTool.decryptWithRandomKey(HexTools.bytesToHexString(AESTool.PROWISE_KEY_HEAD) + str, HexTools.bytesToHexString(bArr));
        } catch (Exception e) {
            Log.e(TAG, "catch a exception when constrct SaharaData\n" + e);
            strDecryptWithRandomKey = "";
        }
        String[] strArrSplit = strDecryptWithRandomKey.split("/");
        if (strArrSplit.length == 2) {
            this.mUserPs = strArrSplit[0];
            this.mUserKey = strArrSplit[1];
        }
    }

    public byte[] getCipherData(String str) {
        try {
            return HexTools.toByte(!TextUtils.isEmpty(this.mData) ? HexTools.toHex(this.mData) : AESTool.encryptWithRandomKey(HexTools.bytesToHexString(AESTool.PROWISE_KEY_HEAD) + str, "" + this.mUserPs + "/" + this.mUserKey));
        } catch (Exception e) {
            Log.e(TAG, "catch a exception when getCipherData\n" + e);
            return new byte[0];
        }
    }

    public String getUserPs() {
        return this.mUserPs;
    }

    public String getUserKey() {
        return this.mUserKey;
    }

    @Override // com.seewo.libnfc.customer.NfcData
    public NfcData.Customers getCustomer() {
        return NfcData.Customers.SAHARA;
    }

    @Override // com.seewo.libnfc.customer.NfcData
    public String toString() {
        return "SaharaData [mCustomer=" + getCustomer() + ", mUserPs=" + this.mUserPs + ", mUserKey=" + this.mUserKey + "]";
    }
}
