简体   繁体   English

Mifare Classic 1k写密钥

[英]Mifare Classic 1k write keys

I'm trying to make an Android application to write NFC tags. 我正在尝试制作一个Android应用程序来编写NFC标签。 To see how to do that, I've downloaded an example. 为了查看如何执行此操作,我下载了一个示例。 However, the example does not work. 但是,该示例不起作用。 It says it can't authenticate. 它说它不能认证。 That can only mean that it uses an incorrect key for this type of card. 这只能表示它为这种类型的卡使用了错误的密钥。 The strange thing is, even the KEY_DEFAULT and KEY_MIFARE_APPLICATION_DIRECTORY keys are not working on my blank cards. 奇怪的是,即使KEY_DEFAULTKEY_MIFARE_APPLICATION_DIRECTORY键也无法在我的空白卡上使用。 Did Mifare change the keys in any way? Mifare是否以任何方式更改了按键?

EDIT: here's my code. 编辑:这是我的代码。

            /* Authenticate the MAD Sector, sector 1, with key A */
        succes = mClassic.authenticateSectorWithKeyA(
                1, key);
        if (succes) {
            /* Authentication succeeded */

            /*
             * This will read a 16-byte block in this sector
             * It is an I/O operation and will block until complete.
             * It must not be called from the main application thread.
             **/
            b.append(mClassic.readBlock(1), 0, 16);
            b.append(mClassic.readBlock(2), 0, 16);
            b.append(mClassic.readBlock(3), 0, 16);
            data = b.toByteArray();
        }
        /* Authentication failed */
        else
            sb.append("Authentication failed");
        mClassic.close();

    }

I've tried it with the following keys already: 我已经尝试使用以下键:

MifareClassic.KEY_DEFAULT
MifareClassic.KEY_MIFARE_APPLICATION_DIRECTORY
00 00 00 00 00 00
ff ff ff ff ff ff

all to no avail.. 都无济于事..

I am not familiar with the Ubiqconn Tablet PC. 我对Ubiqconn平板电脑不熟悉。 First thing I would do is to check whether the NFC implementation in the device actually supports MIFARE. 我要做的第一件事是检查设备中的NFC实现是否实际上支持MIFARE。 In your main activity's onCreate() add: 在您的主要活动的onCreate()添加:

public void onCreate(Bundle bundle) {
  ...
  if (!getPackageManager().hasSystemFeature("com.nxp.mifare")) {
    Toast.makeText(this, "No MIFARE support!", Toast.LENGTH_LONG).show();
  }
}

Either you have bug in your app(s), or the keys have been customized. 您的应用程序中有错误,或者密钥已被自定义。 Use an app like NFC TagInfo to check whether you can read/write the cards with default keys. 使用类似NFC TagInfo的应用程序检查您是否可以使用默认密钥读取/写入卡。 If it doesn't work, contact whoever sold you the cards and ask them what are the keys. 如果不起作用,请与向您出售卡的人联系,并询问其钥匙是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM