How to use a custom hash function?


I was reading through some multihash stuff and stumbled upon the “how do i add hash functions to the table” question with a very interesting answer under point 2!

(2) If your function is only for your application, you can add a hash function to the table in a range reserved specially for this purpose. See the table.

Now, conceptually this would probably be the same as encrypting your data first then adding it to IPFS.
For the publicly visible IPFS structure it also doesn’t matter. As you keep seeing that file.

But from a usability point of view, this is wildly different!
If the answer on that question is still the same then you would get a hash with some unique start that only some (or one) specific applications know how to handle.

2 questions.

  1. How do you “add a hash function to that table”? I couldn’t find any information on that.
  2. How do you implement handling that custom hash? Like using it for adding a file, but using the decryption path for cat’ting the file?

For me this, for the moment, looks like a nice way to integrate custom hashing functionality as a sort of IPFS plugin of sorts. Something that could automate the encrypt-then-add logic, not that it’s that complicated either.