Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

CardExchange Producer can capture and store a MIFARE DESFire’s card UID at the time of print. The card UID can be converted to decimal and hexadecimal with the help of Python scripting in the Card Designer.

Requires: CardExchange Producer v10 Business edition or higher

Step Process

To write a Python script that does the DESFire UID manipulation, please refer to the steps below:

 

STEP Step 1:

Create a new Variable (Example: var_uid) and give it the value of the UID from your database.

...

STEP 2:

Drag the var_uid to the card layout.

...

STEP 3:

Insert in function the Python script:MIFARE DESFire definition, and set up the configuration of the DESFire application according to your preferences.

...

Step 2:

Insert a Text box on the card.

...

Step 3:

A window will pop up, and you change the “Fixed Value” to “Script”.

...

Step 4:

After you change the “Fixed Value” to “Script” you define it as uid_var. A new window will appear where you attribute the uid_var the value of UID. Then Press Ok.

...

Step 5:

Your Insert new object window should look like the following image, and then you click on the arrow on the left side of var_uid.

...

Step 6:

Select MIFARE DESFire UID.

...

Step 7:

Go to functions.

...

On the Functions tab, insert the Python Script.

Example: Last 8 Numbers

uid = uid_var

str = str(uid)

x = len(str)

uid_var = str[x-8:x] 8 is set as a example:

...

STEP 4:

Go to Data\Variables double click on the variable name in this case is: var_uid and give it the value of MIFARE DESFire UID.

 

...

STEP 5:

Go to content and change the window option to script.

...

After that, please close the properties window

...

Code explanation:

uid = uid_var
str = str(uid)
sizeOfUid = len(str)
numberOfChars = 8
uid_var = str[sizeOfUid-numberOfChars:sizeOfUid]

Close the properties window, save the changes made, and you should have the expected result.

To convert the DESFire to UID, follow this next article to achieve the hex format in the card design:

https://cardexchangesolutions.atlassian.net/l/cp/VsdCQdhL