Ecriture et Lecture sur smart card

nata - Modifié par Whismeril le 6/11/2013 à 18:26
 nata - 6 nov. 2013 à 22:22
Bonjour,
j ecris un programme en c# pour lire et ecrire sur une smart card. jusque la j arrive a lire et a ecrire dessus mais les donnees ecrites ne sont pas sauvegardes quand j enleve la carte.
Quelqu'un sait il comment je peux faire ca

3 réponses

Whismeril Messages postés 19028 Date d'inscription mardi 11 mars 2003 Statut Non membre Dernière intervention 24 avril 2024 656
6 nov. 2013 à 18:26
Bonsoir,

pour pouvoir te répondre, il nous faudrait le code que tu utilises.
De plus ton tite "TextBox" n'a pas grand chose à voir avec ta question, je le modifie.
0
Oui j ai ecris textbox car comme j ai un textbox ou s affiche les informations de la carte je voulais faire un autre textbox dedans qui sera une zone ou ecrire puis sauvegarder cette ecriture.
est ce possible?
0
Whismeril Messages postés 19028 Date d'inscription mardi 11 mars 2003 Statut Non membre Dernière intervention 24 avril 2024 656
6 nov. 2013 à 20:39
Sans doute, mais sans le code que tu utilises, on ne pourra pas t'aider.
N'oublie pas la coloration syntaxique, bouton <>
0
voici le code que j utilise pour analiser et visualiser les infos de la carte:

public void AnalyzeCard(CardTerminalSlot aCardSlot)
{
// Acquire any processor card (T=0 or T=1) that may be present in the given card
// terminal slot
string readerName = aCardSlot.CardTerminalName;

CardActivationResult nActivationResult;
DisplayText("Reader Name: " + readerName);

// Note: not all reader drivers return a Reader ID.

DisplayText("Reader ID: " + aCardSlot.CardTerminal.ProductAdditionalInfo);
CardHandle aCard = aCardSlot.AcquireCard((CardTypes.T0 | CardTypes.T1), out nActivationResult);
if (nActivationResult != CardActivationResult.Success)
{
Debug.Assert(aCard == null);

switch (nActivationResult)
{
case CardActivationResult.NoCard:
m_aPromptLabel.Text = readerName + ": Please insert card ...";
break;
case CardActivationResult.UnresponsiveCard:
m_aPromptLabel.Text = readerName + ": Unresponsive card.";
break;
case CardActivationResult.InUse:
m_aPromptLabel.Text = readerName + ": Card in use";
break;
default:
m_aPromptLabel.Text = readerName + ": Can't power up card!";
break;
}
return;
}

// we now have a card in the reader that is powered up
m_aPromptLabel.Text = readerName + ": Found card";
DisplayText("Found card in reader " + aCardSlot.CardTerminalName);

try

{
// =========================== ATR DETECTION ======================================
// Every card accessed through PC/SC must return an Answer To Reset (ATR).
// So let's see what we've got here.

byte[] atr = aCard.GetATR();
if (atr.Length == 0) throw new Exception("Invalid ATR");
DisplayText("ATR: " + CardHex.FromByteArray(atr, 0, atr.Length));

// ================================================================================

// Go a little deeper: is this a contact or contactless card system we are dealing with?
Program cardHelper = new Program(aCard);
if (cardHelper.isContactless)
{
DisplayText(cardHelper.cardInfo);

// =========================== APDU EXCHANGE ==================================

byte CL_CLA = 0xFF;
byte CL_INS_GET_UID = 0xCA;
byte P1 = 0;
byte P2 = 0;

CardCommandAPDU aCmdAPDU = new CardCommandAPDU(CL_CLA, CL_INS_GET_UID, P1, P2, 256);
CardResponseAPDU aRespAPDU;
aRespAPDU = aCard.SendCommand(aCmdAPDU);

if (!aRespAPDU.IsSuccessful)
{
DisplayText("WARNING: can't get a UID - this might be a contact card");
}
else
{
byte[] uidWithSw12 = aRespAPDU.GenerateBytes();
if (uidWithSw12.Length < 2) throw new Exception("Invalid UID");
DisplayText("UID: " +
CardHex.FromByteArray(uidWithSw12, 0, uidWithSw12.Length - 2));
}
//writeData(aRespAPDU, 1);
DisplaytextTest("Salut tout le monde");
}
//============================= Write data in smart card ========================================

Program HIDcard = new Program(aCard);
byte[] atr1 = {0x01, 0x00, 0x7D, 0x00, 0x00, 0x78 };
DisplaytextTest("la = " + HIDcard.setData(10, 20));
}
catch (Exception x)
{
Trace.WriteLine(x.ToString());
DisplayText(x.ToString());
m_aPromptLabel.Text = "Card access error";
}
finally
{
aCard.Dispose(); // release card handle
}
}


si quelqu un a une idee
0
Rejoignez-nous