G
G
gd1xza2021-01-15 12:19:06
Communication protocols
gd1xza, 2021-01-15 12:19:06

Using hash functions instead of internet checksum?

This is how the internet checksum (py) is calculated:

def checksum(data):
 data = data.hex(' ')
 hexinput = '0x'+data
 hexinput = "".join(hexinput.split())
 quads = [int(hexinput[i:i+4],16) for i in range(2, len(hexinput), 4)]
 sumstuff = hex(sum(quads))
 if len(sumstuff) > 6:
   manip = str(sumstuff)
   sumstuff = hex(int(manip[2],16)+int(manip[3:],16))
   s = hex(int(sumstuff,16) ^ 0xffff)[2:]
   return s


Is it reasonable to use the sha hash function or others in network protocols for the purpose of calculating the checksum?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2021-01-15
@bacon

What is "internet checksum"?
Start with what the "checksum" is for and how the hash function will help you in this situation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question