Firstly, I need to say my specific problem so that this question won't marked as duplicated.
I've an android phone that has already root access and bootloader lock open. And recently I dropped it and its screen (lcd panel) was blacked out and no feedback about screen. But locally its touch panel %90 of screen was working because someone calls me it can answer and rejecet call if you swipe it from its oginal coordinates of screen.
However, I connect it from Vysor app to see screen and it was successfully done its process but I couldn't backup at that position because of time limitation about my life. A day later, I tried it again but not worked. After this I reset it but now it ask me to enter password manually for first time and fingerprint doesn't work. At this step I forced to power loss (by holding power button of phone) to start it from bootlader. And I started it from bootloader and boot from my previously used twrp.img version that has ability of decrypt password and was confirmed previously time before this happened. After this step it decrypted successfully and I deleted /data/system/gatekeeper.pattern.key after I backedup 58 bytes file. Now I have backup of .key file. After that I reboot phone to open normally but it doesn't ask password also doesn't decrypt userdata partiton. And stuck on
Phone is starting... screen.
Now, I realised that I set password again with same value from when system was awake. so my partition was encrypted before it was successfully decrypted. So if my password is true the TWRP security codes (that check if is successfully decrypted it) but it fails even if I use correct password. So I need to find algorithm of decryption and I will apply algorith twice.
In short, I need somehing like that but it won't check if password correct or not
twrp decrypt $PASS ; twrp decrypt $PASS.
otherwise it will fail on first time so second time and so on it will repeats.