Ejemplo n.º 1
0
 public void Decode(byte[] bytes)
 {
     for (int i = 0; i < bytes.Length;)
     {
         var(tag, tagLength) = BerHelpers.DecodeTag(Helpers.ArraySlice(bytes, i, bytes.Length));
         i += tagLength;
         Add(tag);
     }
 }
Ejemplo n.º 2
0
 public void Decode(byte[] bytes)
 {
     for (int i = 0; i < bytes.Length;)
     {
         var(tag, tagLength) = BerHelpers.DecodeTag(Helpers.ArraySlice(bytes, i, bytes.Length));
         i += tagLength;
         var(length, lengthlength) = BerHelpers.DecodeLength(Helpers.ArraySlice(bytes, i, bytes.Length));
         i        += lengthlength;
         this[tag] = (int)length;
     }
 }
Ejemplo n.º 3
0
        private Tlv.Tlv BuildDol(DataObjectList dol, Transaction trx)
        {
            var tlv = new Tlv.Tlv();

            foreach (var item in dol)
            {
                switch (item.Key)
                {
                case 0x9F02:
                    tlv[item.Key] = BerHelpers.EncodeUint((ulong)trx.Amount);
                    break;

                case 0x9F03:
                    tlv[item.Key] = BerHelpers.EncodeUint((ulong)trx.AdditionalAmount);
                    break;

                case 0x9F1A:
                    tlv[item.Key] = BerHelpers.EncodeUint((ulong)this.config.Terminal.CurrencyCode);
                    break;

                case 0x95:
                    tlv[item.Key] = BerHelpers.EncodeUint(this.tvr);
                    break;

                case 0x5F2A:
                    tlv[item.Key] = BerHelpers.EncodeUint((ulong)this.config.Terminal.CurrencyCode);
                    break;

                case 0x9A:
                    tlv[item.Key] = BerHelpers.EncodeUint((ulong)trx.Date.Ticks);
                    break;

                case 0x9C:
                    tlv[item.Key] = BerHelpers.EncodeUint((ulong)trx.Type);
                    break;

                case 0x9F37:
                    tlv[item.Key] = GenerateRandomNumber(item.Value);
                    break;

                case 0x9F35:
                    tlv[item.Key] = BerHelpers.EncodeUint((ulong)this.config.Terminal.Type);
                    break;

                case 0x9F45:
                    tlv[item.Key] = dataAuthenticationCode.ToArray();
                    break;

                case 0x9F34:
                    tlv[item.Key] = BerHelpers.EncodeUint(cvr);
                    break;

                default:
                    if (CardInformation.Raw.TryGetValue(item.Key, out byte[] value) || this.ProcessingOptions.Raw.TryGetValue(item.Key, out value))