File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed
Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,16 @@ def xor_hash(data: bytes) -> int:
2727 result ^= char
2828 return result
2929
30- def generate_hash (name : str , key_bytes : bytes ) -> int :
31- """Generate the channel number by hashing the channel name and psk bytes."""
32- # If key_bytes is the default "AQ==", use the fallback key
33- if base64 .b64encode (key_bytes ).decode ("utf-8" ) == "AQ==" :
34- key_bytes = base64 .b64decode ("1PG7OiApB1nwvP+rz05pAQ==" )
35- h_name = xor_hash (name .encode ("utf-8" ))
30+ def generate_hash (name : str , key : str ) -> int :
31+ """generate the channel number by hashing the channel name and psk"""
32+ if key == "AQ==" :
33+ key = "1PG7OiApB1nwvP+rz05pAQ=="
34+ replaced_key = key .replace ("-" , "+" ).replace ("_" , "/" )
35+ key_bytes = base64 .b64decode (replaced_key .encode ("utf-8" ))
36+ h_name = xor_hash (bytes (name , "utf-8" ))
3637 h_key = xor_hash (key_bytes )
37- return h_name ^ h_key
38+ result : int = h_name ^ h_key
39+ return result
3840
3941class Node :
4042 """A model of a (local or remote) node in the mesh
You can’t perform that action at this time.
0 commit comments