tanersahindotnet / NFCAndroidExample

NFC Card Reader Example Using Xamarin.Android
13 stars 5 forks source link

Mifare Ultralight INT 32 Crash #1

Closed anouk closed 1 year ago

anouk commented 3 years ago

https://github.com/tanersahincom/NFCAndroidExample/blob/43c4f2fc6a847f9086bb63b085e0ae160630f9a6/NFCAndroidExample/MainActivity.cs#L101

Reading Mifare Ultralight caused application to crash with INT32. Resolved by changingto 64

var number = Convert.ToInt64(num, 16);

tanersahindotnet commented 2 years ago

Thanks for your contribution

macanovic commented 2 years ago

Actually, both Convert.ToInt32 should be changed to Convert.ToUInt64 Usually all hex strings are interpreted as unsigned integers, otherwise, the result is very often negative. Tested with several cards, Desfire EV2, EV3, Classic EV1 I found this code very useful, nice proof of concept code :)