HTC One M8 encrypted it's self, decyption failed, data corrupt, reset doesn't work
You can try to download and install the firmware via fastboot. 
HTC provides the firmware for a lot of One M8 variants.

Or you unlock the bootloader (oficcially supported by HTC) and install Lineage OS. That would get Android 7 to your device. Even if Lineage has only nightly builds for the One M8, the nightlies of Lineage OS are usually relatively stable (my experience on a different device). Also the encryption usually works and it is better to have a working phone on Lineage than a bricked one.

Note: Even if you do not plan to install Lineage oem unlock may be interesting for you as it erases the user data partition. Afterwards you can still re-lock it.