title: Best practices for passing encrypted data between different programming languages
body: <p>I have read that if you want to encrypt a string using one programming language and decrypt that string using another programming language, then to ensure compatibility it is best to do some conversions prior to doing the encryption. I have read that it's a best practice to encrypt the byte array of a string rather than the string itself. Also, I have read that certain encryption algorithms expect each encrypted packet to be a fixed length in size. If the last packet to be encrypted isn't the required size, then encryption would fail. Therefore it seems like a good idea to encrypt data that has first been converted into a fixed length, such as hex. </p>
  
  <p>I am trying to identify best practices that are generally useful regardless of the encryption algorithm being used. To maximize compatibility when encrypting and decrypting data across different languages and platforms, I would like a critique on the following steps as a process:</p>
  
  <p><strong>Encryption:</strong></p>
  
  <ul>
  <li>start with a plain text string</li>
  <li>convert plain text string to byte array</li>
  <li>convert byte array to hex</li>
  <li>encrypt hex to encrypted string</li>
  <li>end with an encrypted string</li>
  </ul>
  
  <p><strong>Decryption:</strong></p>
  
  <ul>
  <li>start with an encrypted string</li>
  <li>decrypt encrypted string to hex</li>
  <li>convert hex to byte array</li>
  <li>convert byte array to plain text string</li>
  <li>end with a plain text string</li>
  </ul>