| | |
| | | package com.dayu.recharge.tools; |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Intent; |
| | | import android.nfc.NfcAdapter; |
| | | import android.nfc.Tag; |
| | | import android.nfc.tech.MifareClassic; |
| | | import android.util.Base64; |
| | | import android.util.Log; |
| | | |
| | | import java.io.IOException; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.InvalidKeyException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | |
| | | import javax.crypto.BadPaddingException; |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.IllegalBlockSizeException; |
| | | import javax.crypto.NoSuchPaddingException; |
| | | import javax.crypto.SecretKey; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | |
| | | /** |
| | | * @author zx |
| | |
| | | private static NFCWriteHelper helper; |
| | | private static int PASSWORD_LENTH = 12; |
| | | |
| | | public NFCWriteHelper(Intent intent) { |
| | | public NFCWriteHelper(Intent intent, Activity activity) { |
| | | super(activity); |
| | | this.tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); |
| | | } |
| | | |
| | |
| | | * @param intent |
| | | * @return |
| | | */ |
| | | public static NFCWriteHelper getInstence(Intent intent) { |
| | | public static NFCWriteHelper getInstence(Intent intent, Activity activity) { |
| | | if (helper == null) { |
| | | helper = new NFCWriteHelper(intent); |
| | | helper = new NFCWriteHelper(intent, activity); |
| | | } |
| | | return helper; |
| | | } |