First I am sending the requested file from the server to the client and after that I want to send the computed sha of the file from the server to the client, so that the client can check if both the sha from the sent and the received files are the same.
I manage to send the file but when I try to also send the sha (which is a variable) I receive a error ( i believe that the sha is also added to the file content)
How can i send them separately?
if (reqCommand == 'get'):
with open (reqFile, 'rb') as in_file, open(encFile, "wb") as out_file:
encrypt(in_file, out_file, "abc")
f = open(encFile,'rb')
for data in f:
# print 'here3'
conn.sendall(data)
f.close()
file_sh = hashfile(reqFile)
print 'the sha1 function from the server: ', file_sh
conn.send(file_sh)
and the client:
while True:
data = sock.recv(1024)
if not data:
break
#print data
file_to_write.write(data)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…