title: generating you tor hostname from your tor private_key with python
body: <p>I've been trying to generate my tor hostname from my private_key with python3.
  I've used this <a href="https://timtaubert.de/blog/2014/11/using-the-webcrypto-api-to-generate-onion-names-for-tor-hidden-services/" rel="nofollow noreferrer">tutorial(java)</a> and tried to change it to what i want to achieve, but i cant seem to generate my hostname. I suspect that the error lies somewhere in the slicing at the last line, but i cant find any documentation about it.</p>
  
  <pre><code>from Crypto.PublicKey import RSA
  from base64 import b32encode as b32
  import hashlib
  
  privkey= open('privkey',"r")
  #print(key.read())
  key = RSA.importKey(privkey.read())
  pubkey = key.publickey()
  print(b32(hashlib.sha1(pubkey.exportKey()[22:).digest()[:10]))
  </code></pre>
  
  <p>also, my goal is to do it as easy understandable as possible, and <a href="https://stackoverflow.com/questions/25515593/generating-private-key-and-hostname-for-tor-hidden-service-in-python">this answer</a> seems overly complicated to me.</p>