When trying to call ProtectedData.Protect or ProtectedData.Unprotect in a Win32 build using IL2CPP I get the error “operation is not supported in this platform” but if I build for Win32 with Mono it works perfectly:
Screen shot from the attached debugger for an IL2CPP build:
Screen shot for an attached debugger for a Mono build of the same code:
To get the code to compile at all I have added a csc.rsp file with the line -r:System.Security.dll. I have also tried link.xml files but without any luck. Any suggestions would be greatly appreciated before I create an issue on the issue tracker.
IL2CPP does not support all of the same parts of the class libraries as Mono support, and this is one of them. I’d recommend using the Mono scripting backend if this is something that you need.
Oh dear, that is a bit of an inconvenience. Do you know if this is something that would be implemented later but in the meantime do you know of any alternatives or workarounds that I could consider?
We will probably not be supporting these with IL2CPP, since the code in System.Security.Cryptography tends to pull in a large amount of managed code in a way that is not friendly to managed code stripping. This means that it will lead to large increases in output binary size on AOT platforms, even for project that don’t make use of it.
I’m not too familiar with the encryption library landscape, but you may be able to find third party libraries in native or managed code that can do this as well.