Android Open Source - android-nfc-reader Converter






From Project

Back to project page android-nfc-reader.

License

The source code is released under:

MIT License

If you think the Android project android-nfc-reader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.mklbravo.lib.nfcreader.utils;
/*from   ww w . ja  v a  2  s  . c o  m*/
import java.math.BigInteger;

public class Converter {
  /**
   * Convert byte array into hexadecimal string
   */
  public static String byteArrayToHexString(byte[] data) {
    if (data==null)return "";
    return String.format("%0" + (data.length * 2) + "X", new BigInteger(1, data));
  }

  /**
   * Convert a hexadecimal String into a byte array
   */
  public static byte[] hexStringToByteArray(String s) {
    int len = s.length();
    byte[] data = new byte[len / 2];
    for (int i = 0; i < len; i += 2) {
      data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
          + Character.digit(s.charAt(i + 1), 16));
    }
    return data;
  }
}




Java Source Code List

net.mklbravo.lib.nfcreader.NFCReader.java
net.mklbravo.lib.nfcreader.contracts.TagTech.java
net.mklbravo.lib.nfcreader.interfaces.TagReader.java
net.mklbravo.lib.nfcreader.readers.AbstractReader.java
net.mklbravo.lib.nfcreader.readers.MifareClassicReader.java
net.mklbravo.lib.nfcreader.tags.AbstractTag.java
net.mklbravo.lib.nfcreader.tags.MifareClassicTag.java
net.mklbravo.lib.nfcreader.utils.Converter.java