I am trying to call RNGCryptoServiceProvider-> GetBytes () from PHP through the COM level. I can connect it to the class, but every time I call the method, I get one of two errors (related to the parameter). I think this is because GetBytes accepts an array of bytes with a fixed size by reference. Since PHP does not support fixed-size strings, which is interesting:
Error 1:
$util = new \DOTNET( 'mscorlib', 'System.Security.Cryptography.RNGCryptoServiceProvider' ); $data = new \Variant(str_repeat(chr(46), $size), VT_UI1 | VT_ARRAY); $util->GetBytes($data);
Error [0x80070057] Invalid parameter
What is selected by the line ->GetBytes() .
If I do not use the option, but just use a simple string, I still get the same error.
However, if I pass the array this way:
$data = array(''); $util->GetBytes($data);
Parameter 0: type mismatch.
So, I think the option / string approach is correct (since it passes the type check of the parameter). But I just can't figure out how to make it work.
C # interface for the method :
public override void GetBytes( byte[] data )
thanks
source share