I don't completely understand the algorithm that's being employed here, but at least the code is no longer hideous machine-generated unreadable nonsense. Should be much easier to translate to other languages now.
After messing with my home system for a bit, I realized that the encryption was not actually working and my password was getting rejected. I found a different decompiler which generated different (more sensible) code which is now generating the same password as the desktop Pentair app and is able to remotely login. This code needs a lot of manual deobfuscation.
This brings along proper password encryption and validation for the login process (which is still not needed for local connections).
You can run the remote connection tests by passing a system name and password as 2 arguments (so the system name needs to be quoted, e.g.: `test "Pentair: xx-xx-xx" 1234`)
Also updated to latest .NET Core and C# versions while I was at it.
Converted as much ugly code as I could find into appropriate C#-friendly versions. For example, all the manual ByteHelper stuff, buffer index tracking, etc. are now BinaryWriters/BinaryReaders. Also cleaned up a bunch of getter and setter methods to use C# properties.
There's still more to be done here, but this greatly simplifies the code for reading and comprehension.
Added circuit data to pool status message
Sanitized byte signedness
Added helper to get pool/spa on/off state from pool status
Added simple color class
Removed debug output
Added basic status output to test program