我正在写一个带有64块的1kb mifare卡,我需要特别避免每个第4块,即扇区预告片,即块3,7,11,15,19,23,27,31,35,39 .....,63; 我在写入之前已经对块进行了身份验证。
正在运行这样的循环: 请,我需要帮助避开扇区预告片,我的代码只是遍历写入它的所有块,因此损坏了卡。
int block = 0;
byte[] array = ImageConvert();
string hex = ByteArrayToString(array);
Image x = (Bitmap)((new ImageConverter()).ConvertFrom(array));
foreach (byte[] copySlice in array.Slices(16))
{
Console.WriteLine(ByteArrayToString(copySlice));
if (block == 0)
AuthBlocks.Auth4(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 4)
AuthBlocks.Auth8(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 8)
AuthBlocks.Auth12(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 12)
AuthBlocks.Auth16(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 16)
AuthBlocks.Auth20(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 20)
AuthBlocks.Auth24(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 24)
AuthBlocks.Auth28(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 28)
AuthBlocks.Auth32(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 32)
AuthBlocks.Auth36(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 36)
AuthBlocks.Auth40(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 40)
AuthBlocks.Auth44(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 46)
AuthBlocks.Auth48(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 48)
AuthBlocks.Auth52(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 52)
AuthBlocks.Auth56(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 56)
AuthBlocks.Auth60(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
if (block == 60)
AuthBlocks.Auth60(readerFunctions_, KEYTYPES.ACR122_KEYTYPE_A, 00);
block++;
writeblocks(block, copySlice);
}
这是我的WriteBlock方法:
void writeblocks(int block, byte[] data)
{
try
{
byte[] buff = new byte[16];
buff = data;
if (buff.Length < 16)
Array.Resize(ref buff, 16);
myhelper.addTitleToLog(richTextBox1, false, "Update Binary");
mifareClassic_.updateBinary((byte)block, buff, (byte)(16));
myhelper.addMsgToLog(richTextBox1, "Update success");
MessageBox.Show("success");
}