HTC One M8 encrypted it's self, decyption failed, data corrupt, reset doesn't work I have a HTC One M8 not rooted. Yesterday, when I was checking voicemail, the phone was going really slow and rebooted after a minute or so.  Worked fine after that until tonight.  The phone was on my desk in front of me (doing nothing on it for a couple hours) and I saw it reboot again and seemed to be taking longer than usual to boot.  Then I got the message:

Your phone is encrypted. To decrypt your phone, enter your screen lock password. 30 attempts remain before device data is deleted.

There was a button for emergency call and the keyboard popped up for me to enter my password and hit the decrypt button.  I entered the password and got:

Decryption unsuccessful.  The password you entered is correct, but unfortunately your data is corrupt.  To resume using your phone, you need to perform a factory reset.  When you setup your phone after the reset, you'll have an opportunity to restore any data that was backed up to your Google account.

There was a reset phone button.  I didn't have much on my phone that I didn't have elsewhere, so I hit the reset button.  After the reboot, it went back to the "Your phone is encrypted" message and data still corrupt.  I googled how to reset the phone.  I shut down the phone, held the down volume button and power button to get to the menu with fastboot, recovery, factory reset, simlock, check smartsd, image crc, and show barcode.  Image crc and show barcode worked but did nothing to fix the phone of course.  Simlock got SD init OK, Open MCCMNC file fail, Open CID file fail, Open IMEI file fail, Open atsdob file fail, Open SF file fail, Open mane file fail, Check keycard fail, process done, reboot device? All the others just ended up with me back at the Your phone is enctryped message again.

I did not encrypt the phone, so I don't know why I got this message unless it's just an error from apparently having corrupt data.  Any idea on what to try?  I obviously lost anything that's on the phone that I don't have elsewhere, but I'd be fine with the reset back to not been used yet state.

The phone has plenty of power.  It was around 70% when this happened.  It's fully charged now.

::edit::

After doing some more searches, I went to htc's website to get the rom to flash it back to factory settings manually, but both in the hold volume down plus power button boot and letting it boot normally until it got to the decryption failed, it didn't work.  I tried 5 different usb cables on two different computers.  None would keep the phone connected long enough to do much of anything.  I had installed the htc manager so it had drivers, but the phone only showed up in device manager.  It did not show up in file explorer.  In regular boot, it could just not find the phone to try and update it.  Off the fastboot usb screen, it got far enough to show I was already on the current version but let me pick to install anyway.  However, the first thing it did was try and reboot, which only went back to the phone encrypted message and went no further.

I'm thinking it's a lost cause, and I'll have to get a new one.
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.