bin_to_hex 添加异或解密,添加ReadMe.txt
This commit is contained in:
		@@ -203,7 +203,8 @@ def bin_to_hex(bin:bytearray,f):
 | 
			
		||||
  turned_old=0
 | 
			
		||||
  out_text=''
 | 
			
		||||
  if(pkt_header_check(bin)):
 | 
			
		||||
    out_text+=tran_pkg_header(bin[0:96])+'\n'
 | 
			
		||||
    out_text=tran_pkg_header(bin[0:96])+'\n'
 | 
			
		||||
    f.write(out_text)
 | 
			
		||||
  while turned < all_size:
 | 
			
		||||
    if(turned+pack_size<=all_size):
 | 
			
		||||
      data=bin[turned:turned+pack_size]
 | 
			
		||||
@@ -228,9 +229,13 @@ def bin_to_hex(bin:bytearray,f):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def bin_to_hex_file(bin_file_name:str,hex_file_name:str):
 | 
			
		||||
def bin_to_hex_file(bin_file_name:str,hex_file_name:str,enc=0):
 | 
			
		||||
  with open(bin_file_name,mode='rb') as f:
 | 
			
		||||
    bin=f.read()
 | 
			
		||||
    bin=bytearray(f.read())
 | 
			
		||||
    if(enc):
 | 
			
		||||
      pat=(bin[0]^0x03)&0xff
 | 
			
		||||
      for index in range(len(bin)):
 | 
			
		||||
        bin[index]=bin[index]^pat
 | 
			
		||||
  with open(hex_file_name,mode='w+',encoding="utf-8") as f:
 | 
			
		||||
    bin_to_hex(bin,f)
 | 
			
		||||
 | 
			
		||||
@@ -238,4 +243,8 @@ def bin_to_hex_file(bin_file_name:str,hex_file_name:str):
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
  # bin_to_hex_file(sys.argv[1],sys.argv[2],sys.argv[3])
 | 
			
		||||
  # load_flash_info("work/upload-test.info")
 | 
			
		||||
  bin_to_hex_file(sys.argv[1],sys.argv[2])
 | 
			
		||||
  if(len(sys.argv)>=3):
 | 
			
		||||
    enc=1
 | 
			
		||||
  else:
 | 
			
		||||
    enc=0
 | 
			
		||||
  bin_to_hex_file(sys.argv[1],"work/"+sys.argv[1]+".txt",enc)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user