Bob uploads a file to my custom file server locked with a password, which then the file server generates a link for him to share

  • Bob wants to be able to share this data to anyone that has this link
  • Bob doesn't want anyone but the people that have the link and password to access his data, not even the server administrator

I do not want to store any private keys on my file server's filesystem, because that isn't safe in any way if the server were to be compromised.

I have Key Derivation in the works, but when the user session is expired or the server restarts, they would have to re-enter the password for the shared data.

What kind of encryption technique on the file server would I use to solve these issues?

1 Answer 1


You can use a simple symmetric encryption, like ChaCha20-poly1305, to encrypt the data with a key derived from the password, using Argon2id for example.

The key, encoded in base64url, can be appended by the client to the link as a URL fragment. The server (and its administrator) does not need to know the password or the key: the encryption should be entirely done by the client, for example in Javascript if the client is in HTML. If you want to append the key as a URL query, you should take care that the server does not read, process or log it: so it is best not to use queries at all.

The service MEGA is using a similar approach. This just an example of an implementation and not an endorsement of this particular service.

  • 1
    @JoshuaBenfield It depends on against whom you want to protect the data. If it is only from the server, what I suggested is safe: the server does know neither the key nor the plaintext. If you have further needs, then do not append the key to the URL, and share the password to all recipients with a secure communication channel of your choice. The recipients can then derive the key from the password and the decryption can be done by the client-side.
    – A. Hersean
    Jun 1, 2021 at 16:29
  • nice. so simple it confuses those w/moderate knowledge. might want to mention that the derivation should be done in JS too. Might clarify (for the sake of some) the crucial diff between a fragment and a search param.
    – dandavis
    Jun 1, 2021 at 18:29
  • @A.Hersean Ah, I see what you mean now, I thought u meant to actually keep the key fragmented in the URL, I'm not the best with language and context lol. Great idea thanks! Jun 1, 2021 at 22:58
  • 1
    You would definitely want to use the fragment, not the query string, for this. Fragments aren't sent to the server, query strings are. You say "take care that the server does not read, process, or log it" but if the server is compromised then its code will be edited to do those things, so you have to just never let the key/password hit the server at all (also, by default lots of servers log URLs including query strings).
    – CBHacking
    Jun 2, 2021 at 8:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .