igorvc / iso8583py

Automatically exported from code.google.com/p/iso8583py
GNU General Public License v3.0
4 stars 1 forks source link

iso8583py change bit128 #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi:

ASCII to process 
<0110F23A40010A80800000000000060000011688888888888888884010000000000001000702014
92700000601492707020702601106179200059490124182007217211115616888888888888888819
1111111111111111111AE3D1B33>

becase bit128=1,so there is error in ISO8583.py
I have changed something in py file, please diff it with vim.

Original issue reported on code.google.com by wangzha...@gmail.com on 27 Sep 2013 at 7:47

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

Like you can see in the code, the 128º bit is "binary", So:

"def __setBitTypeB(self, bit, value):
                """Method that set a bit with value in form B
                It complete the size of the bit with a default value
                Example: pack.setBit(3,'30000') -> Bit 3 is a B type, so this bit, in ASCII form need to has size = 6 (ISO especification) so the value 30000 size = 5 need to receive more "1" number.
                        In this case, will be "0" in the left. In the package, the bit will be sent like '030000'
                @param: bit -> bit to be setted
                @param: value -> value to be setted
                @raise: ValueToLarge Exception
                It's a internal method, so don't call!
                """
"

So, you cannot have a with "1" and no value, the library wants a binary with 
length = 16.

Please give more information about the problem.

Original comment by igo...@gmail.com on 30 Sep 2013 at 1:06

GoogleCodeExporter commented 9 years ago
Hello:

iso = 
"0110F23A40010A80800000000000060000011662260199201777774010000000000001000702014
92700000601492707020702601106179200059490124182007217211115616622601992017777719
1111111111111111111AE3D1B33"

ISO8583.py(source codes), run python test8583.py
Traceback (most recent call last):
   File "test8583.py", line 19, in <module>
     b.setIsoContent(iso)
   File "/home/wangzhaohe/app/ISO8583Module-1.2/ISO8583/ISO8583.py", 
line 992, in setIsoContent
     self.__inicializeBitsFromBitmapStr(self.BITMAP_HEX)
   File "/home/wangzhaohe/app/ISO8583Module-1.2/ISO8583/ISO8583.py", 
line 519, in __inicializeBitsFromBitmapStr
     self.BITMAP_VALUES[(c +1)* 8] = 'X'
IndexError: list assignment index out of range

*The reason is in line 519:*

     def __inicializeBitsFromBitmapStr(self, bitmap):
         """Method that receive a bitmap str, process it, and prepare 
ISO8583 object to understand and "see" the bits and values inside the 
ISO ASCII package.
         It's a internal method, so don't call!
         @param: bitmap -> bitmap str to be analized and translated to 
"bits"
         """
         bits = []
         for c in range(0,16):
             for d in range(1,9):
                 if self.DEBUG == True:
                     print ('Value (%d)-> %s & %s = %s' % 
(d,self.BITMAP[c] , self._TMP[d], (self.BITMAP[c] & self._TMP[d]) ))
                 if (self.BITMAP[c] & self._TMP[d]) == self._TMP[d]:
                     if d == 1: #  e o 8 bit
                         if self.DEBUG == True:
                             print ('Bit %s is present !!!' % ((c +1)* 8))
                         bits.append((c +1)* 8)
*self.BITMAP_VALUES[(c +1)* 8] = 'X'*
                     else:
                         if (c == 0) & (d == 2): # Continuation bit

*when c=15, c +1* 8==128, but self.BITMAP_VALUES's lenth is 128**, so 
index error displayed.*

     #init with "0" the array of values
     def __inicializeBitmapValues(self):
         """Method that inicialize/reset a internal array used to save 
bits and values
         It's a internal method, so don't call!
         """
         if self.DEBUG == True:
             print ('Init bitmap_values')

         if len(self.BITMAP_VALUES) == 128:
*for cont in range(0,128):*
                 self.BITMAP_VALUES[cont] = self._BIT_DEFAULT_VALUE
         else:
*for cont in range(0,128):*
                 self.BITMAP_VALUES.append(self._BIT_DEFAULT_VALUE)

Here if 128 changes to 129, I think it will be ok.

ISO8583_changed_by_wzh.py, run python test8583.py
['2', 'Primary account number (PAN)', 'LL', 19, 'n']
  value = 166226019920177777

['3', 'Precessing code', 'N', 6, 'n']
  value = 401000

['4', 'Amount transaction', 'N', 12, 'n']
  value = 000000000100

['7', 'Date and time transmission', 'N', 10, 'n']
  value = 0702014927

['11', 'Systems trace audit number', 'N', 6, 'n']
  value = 000006

['12', 'Date and time local transaction', 'N', 6, 'n']
  value = 014927

['13', 'Date effective', 'N', 4, 'n']
  value = 0702

['15', 'Date settlement', 'N', 4, 'n']
  value = 0702

['18', 'Message error indicator', 'N', 4, 'n']
  value = 6011

['32', 'Acquiring institution identification code', 'LL', 11, 'n']
  value = 06179200

['37', 'Retrieval reference number', 'N', 12, 'an']
  value = 059490124182

['39', 'Action code', 'A', 2, 'an']
  value = 00

['41', 'Card acceptor terminal identification', 'N', 8, 'ans']
  value = 72172111

['49', 'Verification data', 'A', 3, 'a']
  value = 156

['102', 'Account identification 1', 'LL', 28, 'ans']
  value = 166226019920177777

['103', 'Account identification 2', 'LL', 28, 'ans']
  value = 191111111111111111111

['128', 'Message authentication code (MAC) field', 'B', 16, 'b']
  value = AE3D1B33

wangzhaohe@gmail.com
2013-10-01

? 2013?09?30? 21:06, iso8583py@googlecode.com ??:

Original comment by wangzha...@gmail.com on 1 Oct 2013 at 1:19

GoogleCodeExporter commented 9 years ago
Yes, this is a bug!
I'll fix it soon!
Thanks

Original comment by igo...@gmail.com on 1 Oct 2013 at 11:03

GoogleCodeExporter commented 9 years ago
Fixed in revision #49.

Original comment by igo...@gmail.com on 7 Oct 2013 at 12:32

GoogleCodeExporter commented 9 years ago
__version__=  '0.3'
not '1.3'

Original comment by wangzha...@gmail.com on 8 Oct 2013 at 4:06

GoogleCodeExporter commented 9 years ago
Would you like to change TAB to 4 blanks?

Original comment by wangzha...@gmail.com on 8 Oct 2013 at 4:08

GoogleCodeExporter commented 9 years ago
Why did not change 128 to 129 in line 351, 794, 911, 1064. If not change these, 
bit128 will not be displayed.

The forms <> and != are equivalent; for consistency with C, != is preferred; 
where != is mentioned below <> is also accepted. The <> spelling is considered 
obsolescent.

Why changed print() to print, python3 will not support print.

Original comment by wangzha...@gmail.com on 8 Oct 2013 at 4:54

GoogleCodeExporter commented 9 years ago
Hi,

I fixed issues that you said in #7: "change 128 to 129 in line 351, 794, 911, 
1064." Thanks.

I look for print's and change that ones without "()". Thanks.

So I released a revision #51

I'll Think about change tab for 4 blanks ...

Best regards,

Original comment by igo...@gmail.com on 8 Oct 2013 at 11:55