Nov-14-2016, 02:37 AM
(Nov-13-2016, 05:16 PM)Ofnuts Wrote: I would vote for using (key,name) tuples instead of separate variables, and then the first choice becomes as palatable as the second.
I'm surprised at the use of '>' on hashes, so either the operator is the wrong one, or your hashes aren't really hashes and your variable names are misleading :)
so, you mean:
if remote_hash > local_hash: use_key, use_name = remote_key, remote_name else: use_key, use_name = local_key, local_name?
what this part of the code is doing is selecting whether remote or local is to be used "at random". both hosts will be doing this and they need to be "in sync" by making the same choice. they are symmetrical in the sense that neither has any predominant state or attribute over the other. each has the other's key. each knows the other as the remote, so in this sense they are making opposite choices. the hash for a host is a hash of it's key and name. both hosts thus can generate the same hashes which provide psuedo-random (weak, but good enough to not be systematically making the same choice too often) decision making.
... remote_key = secure_key_transfer_from_peer_host() remote_hash = hashlib.sha224( remote_name + remote_key ).hexdigest() local_hash = hashlib.sha224( local_name + local_key ).hexdigest()this hash exists only for making this common choice, so each host is using the same shared key, one or the other
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.