Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9010683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:31:40+00:00 2026-06-16T02:31:40+00:00

I’m trying to write some data to a Mifare DesFire card with a Galaxy

  • 0

I’m trying to write some data to a Mifare DesFire card with a Galaxy S3 with following lines:

private byte[] wrapMessage (byte command, byte[] parameters) throws Exception {
    ByteArrayOutputStream stream = new ByteArrayOutputStream();

    stream.write((byte) 0x90);
    stream.write(command);
    stream.write((byte) 0x00);
    stream.write((byte) 0x00);
    if (parameters != null) {
        stream.write((byte) parameters.length);
        stream.write(parameters);
    }
    stream.write((byte) 0x00);

    return stream.toByteArray();
}

boolean isoDepWrite(Tag tag) {
      IsoDep idTag = IsoDep.get(tag);
      idTag.setTimeout(5000);

      String info = "";
      DesfireProtocol dfp = new DesfireProtocol(idTag);
      try {
          idTag.connect();
          info += "Connected to IsoDep Tag...\n";

          int[] appList = dfp.getAppList();
          dfp.selectApp(appList[0]);
          info += "Selected app no: " + appList[0] + "..\n";

          int[] fileList = dfp.getFileList();
          info += "Selected file no: " + fileList[0] + "\n";

          byte[] params = {(byte)fileList[0], 
                           (byte)0x0, (byte)0x0, (byte)0x0, 
                           (byte)0x2, (byte)0x0, (byte)0x0,
                           (byte)0x41, (byte)0x41};
          byte[] message = wrapMessage((byte) 0x3d, params);

          byte[] result = idTag.transceive(message);
          info += "Result bytes: " + convertByteArrayToHexString(result) + "\n";

          toast(info);
          return true;
      } catch (IOException e) {
          info += "Could not connect to IsoDep Tag...\n";
      } catch (Exception e) {
          info += "Error messages: " + e.getMessage() + " -- " + e.getLocalizedMessage() + "\n";
      }

      toast(info);
      return false;
  }

The info I get after the communication is:

Connected to IsoDep tag...
Selected app no: 1109742 // that shows I connected to an Application
Transceieve result bytes: 91 9e  // PARAMETER ERROR

I can connect and read that Application’s files, but the file has 0’s as bytes in it after I try to write. 0x9E is PARAMETER_ERROR, so I’m doing something wrong wrapping/lining the bytes, any samples of bytes or ideas on this?

EDIT: I tried the bytes @nemo recommended:

{0x3d, fileList[0], 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x41, 0x41}

Now I get “67 00” as result bytes, meaning LENGTH ERROR and the file keeps staying the same, only 0’s.

LAST EDIT: I simply created a new byte array by:

wrapMessage(0x3d, rest of the bytes in the list @nemo recommended)

And it finally worked. I changed the old one with the working above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T02:31:41+00:00Added an answer on June 16, 2026 at 2:31 am

    I think you got your Write command wrong, but this is a shot in the dark.

    According to the official DESFire documentation (try searching for M075031) WriteData is defined as follows:

    WriteData(FileNo, Offset, Length, Data)
    

    As a byte stream this would look like this:

    WriteCmd FileNo  Offset (3 byte)  Length (3 byte)  Data (0 to 52 byte)
    [0x3D]   [0x00]  [0x00 0x00 0x00] [0x00 0x00 0x00] [0x00 ... 0x00]
    

    It’s even possible to write 59 byte more than those 52 byte, but that’s not important here.

    IMO you should make a new array with the needed data for the WriteCmd like this:

    {0x3d, fileList[0], 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x41, 0x41}
    

    Which should write 2 (0x2) bytes (0x41 and 0x41) to the file identified by fileList[0].

    Edit: Updated offset, order is LSB to MSB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to render a haml file in a javascript response like so:
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.