feat: create new onion services via api
This commit is contained in:
parent
192dacf760
commit
24cac76f70
10 changed files with 631 additions and 280 deletions
19
app/util/onion.py
Normal file
19
app/util/onion.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
import base64
|
||||
import hashlib
|
||||
|
||||
|
||||
def onion_hostname(onion_public_key: bytes) -> str:
|
||||
p = onion_public_key[32:]
|
||||
|
||||
h = hashlib.sha3_256()
|
||||
h.update(b".onion checksum")
|
||||
h.update(p)
|
||||
h.update(b"\x03")
|
||||
checksum = h.digest()
|
||||
|
||||
result = bytearray(p)
|
||||
result.extend(checksum[0:2])
|
||||
result.append(0x03)
|
||||
|
||||
onion = base64.b32encode(result).decode("utf-8").strip("=")
|
||||
return onion.lower()
|
Loading…
Add table
Add a link
Reference in a new issue