Python: write decimal number into binary file -


i need replace few bytes in asn1 encoded binary file. because of i'm out of asn1 scope, want replace bytes starting @ position 9 (offset) , of length 9 bytes.

i able open file binary write

fh = open("emvdata_3839_test.der", "r+b") fh.seek(8) fh.write(bytearray(9))  fh.close() 

this replace 9 bytes 00 00 00 ....

i need convert number e.g. 123456789012345678 \x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x00\x01... can put fh.write() method , replace old values new. split long number single digits, convert them format \xyy , make bytearray ? ( mean format file.write() can handle)

please consider in python cannot write basic loop without googling :)

thanks much


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -