When one wants to write an application that uses some of the features of Tor in a secure manner it would be helpful if there was a library to do so.

I wonder if there is a library that provides features like the ones the Tor Browser Bundle implements, such as:

  • Only connect through Tor (no way of connecting through other means and thereby leaking data)
  • Using Unix Sockets instead of TCP for added security
  • Providing an interface to Tor's feature to create individual circuits on demand (like Tor Browsers does with tabs)

Maybe some more things, especially in regards to Hidden Services (like setting them up) or the Control Port (directly accessing its functionality). I know there is Stem, but it is written in Python and I think a C library would allow more users to actually make use of it, be it via language bindings or directly.


A bit of Googling has thrown up libtor, which might be worth a look. (It appears not to have been touched for several years though... )

Another option would be to use Stem, but embed it in your C code using Python's C interface. Either that, or use something like Pyrex or Cython to somehow integrate the two. (I haven't tried this myself, so can't provide any examples, I'm afraid.)

For libraries written in other languages - though not, it appears, C - have a look at this entry on Stem's FAQ.

  • I only saw libtor. The Stem FAQ is really interesting. Should have seen that earlier. Thank you! – meee Aug 29 '15 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.