def _long2bytesBigEndian(n, blocksize=0):
 s = ''
 pack = struct.pack
 while (n > 0):
  s = (pack('>I', (n & 4294967295L)) + s)
  n = (n >> 32)
 for i in range(len(s)):
  if (s[i] != '\x00'):
   break
 else:
  s = '\x00'
  i = 0
 s = s[i:]
 if ((blocksize > 0) and (len(s) % blocksize)):
  s = (((blocksize - (len(s) % blocksize)) * '\x00') + s)
 return s

def _long2bytesBigEndian ( n , blocksize = 0 ) : s = '' pack = struct . pack while ( n > 0 ) : s = ( pack ( '>I' , ( n & 4294967295 L ) ) + s ) n = ( n >> 32 ) for i in range ( len ( s ) ) : if ( s [ i ] != '\x00' ) : break else : s = '\x00' i = 0 s = s [ i : ] if ( ( blocksize > 0 ) and ( len ( s ) % blocksize ) ) : s = ( ( ( blocksize - ( len ( s ) % blocksize ) ) * '\x00' ) + s ) return s
convert a long integer to a byte string .