Remove trailing "0d 0a" bytes from a file, using PowerShell
<p>I am trying to encrypt and decrypt files using PowerShell. In this case, I am working with .docx files. After encrypting the file, I passed it onto the decrypt function, and after decrypting it, the file is corrupted when trying to open. </p>

<p>However, after using a hex editor to compare both original and decrypted .docx files, the only difference is that the decrypted .docx file has 2 trailing bytes of "0d 0a".  </p>

<p>I think this is the result of PowerShell's "Set-Content" command. 
(The Out-File command produces a far worse result.)</p>

<p>However, I am not able to just replace all the carriage return and line feed bytes as I would like to preserve the line feeds and carriage returns of the word document.</p>

<p>Is there a way I am able to remove only the trailing bytes of "0d 0a" of the decrypted and already-written .docx file?</p>