-
-
Save wsct/6156471e25521244885b0f60d21cb44e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Represents a raw command to be sent to the smartcard reader. | |
/// </summary> | |
public class RawCommand : ICardCommand | |
{ | |
private byte[] _rawData; | |
/// <summary> | |
/// Accessor to the entire C-APDU in byte array format. | |
/// </summary> | |
public byte[] BinaryCommand | |
{ | |
get => _rawData; | |
} | |
/// <summary> | |
/// Accessor to the entire C-APDU in string format (all bytes are represented in hexa). | |
/// </summary> | |
public string StringCommand | |
{ | |
get => BinaryCommand.ToHexa(); | |
} | |
/// <summary> | |
/// Initializes a new instance. | |
/// </summary> | |
public RawCommand() | |
{ | |
_rawData = Array.Empty<byte>(); | |
} | |
/// <summary> | |
/// Initializes a new instance for arbitrary C-APDU. | |
/// </summary> | |
/// <param name="cAPDU">C-APDU to be assigned as a byte array.</param> | |
public RawCommand(byte[] cAPDU) | |
{ | |
Parse(cAPDU); | |
} | |
/// <summary> | |
/// Initializes a new instance for arbitrary C-APDU. | |
/// </summary> | |
/// <param name="cAPDU">C-APDU to be assigned as a string container (each byte is coded in hexa).</param> | |
public RawCommand(string cAPDU) | |
{ | |
Parse(cAPDU); | |
} | |
public override string ToString() | |
{ | |
return StringCommand; | |
} | |
/// <inheritdoc /> | |
public ICardCommand Parse(byte[] cAPDU) | |
{ | |
_rawData = cAPDU; | |
return this; | |
} | |
/// <inheritdoc /> | |
public ICardCommand Parse(string cAPDU) | |
{ | |
return Parse(cAPDU.FromHexa()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment