title: Encryption in WebSocket
body: <p>I'm creating a software that serves as a WebSocket server to a web application. It serves to basically backup and store important files generated in the web. Some of these files are sensitive and private to the company using the software.</p>
  
  <p>I imagine something like this:
  <a href="https://i.stack.imgur.com/dBAwG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dBAwG.png" alt="Encryption/Decryption example"></a></p>
  
  <p>The message would be a file in String format, and Alice's key would have be the same both in the Web application and in the Desktop application, shared somehow.</p>
  
  <p>My first thought would be to encrypt those files when they're sent and decrypt them on the server. Although, how can I keep consistency of the key used to decrypt it? It doesn't seem safe to share the key via WebSocket so both server and client have the same key. So that's a question in a safety standpoint, what is the best/correct approach to that? Also, do you have any recommendations on encryption/decription libraries for Java and JavaScript that would be compatible?</p>