The story is that I had an instance of a Samsung S4 with stock ROM with encryption enabled. I proceeded to flash Cyanogenmod without doing a factory reset first. This worked. A while later I decided to try reflashing some other ROMs and eventually got to a point where the encryption message was still present (and didn’t accept any credentials). The message being “Enter your PIN or password to use the encrypted device memory”, resulting in a reboot loop.
Crazily, flashing many ROMs (which installed fine) or wiping the data/cache and doing a factory reset from Clockworkmod still didn’t rid the message.
Eventually I found a solution in reflashing stock firmware. I originally got some errors, even doing this, through heimdall:
ERROR: libusb error -4 whilst receiving packet. Retrying... ERROR: Failed to confirm end of file ERROR: RECOVERY upload failed! ERROR: libusb error -4 whilst sending packet. Retrying... ERROR: Failed to send end session packet! Releasing device interface... Re-attaching kernel driver..
Eventually, I acquired a Windows box and tried flashing through Odin. This also failed, noting an inability to write. I proceeded to take the sd card out and try again. Success. I Then went through and installed the ROM on the device. However, I was still prompted by the encryption message.
The final step was to then reboot the phone into recovery mode (stock recovery this time.. not Clockworkmod) and perform another factory reset. Then go through Odin and reflash the phone again. Only now did the phone finally boot into an OS.
Then, the sd card can be re-inserted again and the Samsung ROM will handle the formatting for you.
Note to self: If I plan on using encryption and someday flashing another rom, do a damn factory reset before flashing!