Package org.nfctools.mf.block

Examples of org.nfctools.mf.block.BlockResolver


    MfCard mfCard = lines.size() == 256 ? new MfCard4k(null, null) : lines.size() == 64 ? new MfCard1k(null, null)
        : null;
    if (mfCard == null)
      throw new MfException("unknown card. lines " + lines.size());

    BlockResolver blockResolver = new BlockResolver();

    Map<Integer, MfBlock> blockMap = new HashMap<Integer, MfBlock>();
    int blockNumber = 0;
    Pattern pattern = Pattern
        .compile("S(.*)\\|B(.*) Key: (............).*\\[(................................)\\]");

    for (String data : lines) {
      Matcher matcher = pattern.matcher(data);
      if (matcher.matches()) {
        int sectorId = Integer.parseInt(matcher.group(1));
        int blockId = Integer.parseInt(matcher.group(2));
        byte[] keyA = NfcUtils.convertASCIIToBin(matcher.group(3));
        byte[] blockData = NfcUtils.convertASCIIToBin(matcher.group(4));

        MfBlock resolvedBlock = blockResolver.resolveBlock(mfCard, sectorId, blockId, blockData);
        if (mfCard.isTrailerBlock(sectorId, blockId))
          System.arraycopy(keyA, 0, blockData, 0, 6);
        blockMap.put(blockNumber, resolvedBlock);
        blockNumber++;
      }
View Full Code Here

TOP

Related Classes of org.nfctools.mf.block.BlockResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.