TWRP not asking me to enter password to decrypt I need to restore from a backup. However TWRP stopped asking me for the password to decrypt. In the terminal emulator I tried twrp decrypt 1234 but got the error &quot;Failed to decrypt data&quot;. Whenever I try to use any other feature in TWRP, such as restore, it says &quot;Failed to decrypt data&quot;.  and &quot;extracTarFork() process ended with ERROR: 255&quot;
How can I restore from a backup?
Copied from comments:

TWRP needs a working firmware for decryption. If system vendor or
modem is wiped, the workaround is to format userdata in order to
remove encryption completely, so TWRP can mount it unencrypted.

Through experimenting I was able to get it to work by doing the following. First, try reflashing just TWRP in fastboot mode: fastboot flash recovery twrp.img. This may be enough, but if not se bellow . My phone is an Xperia so replace steps 1. and 2. with however you normally would install firmware.
Steps:

download phone's Firmware as ftf
Use flashtool to flash firmware
Use fastboot to flash TWRP
Use TWRP to wipe all data, but make sure not to wipe the backup you're trying to restore!
Use TWRP to install a new ROM.
Setup new ROM e.g. sign into WiFi
Reboot to TWRP again
Now TWRP should ask for password and you will be able to decrypt