Hi Mohammad,
If you can use .NET Core, you could reference Nuget package with MIP SDK Mobile.
Then you can make a connection and get the Connection Id via reflection (it is not publicly exposed).
Code would look like this:
var maxCommandTimeout = TimeSpan.FromSeconds(30);
var connection = new Connection(VideoOS.Mobile.Portable.MetaChannel.ChannelTypes.HTTP, "mobile_servre_address", 8081);
var connResponse = connection.Connect(new ConnectParams(), maxCommandTimeout);
var loginResponse = connection.LogIn("username", "passwrod", "", maxCommandTimeout, UserType.Basic);
// search for this via reflection
// connection._connectionId
Alternatively you can use directly the DHEncryption class from the VideoOS.Mobile.Portable.Encryption namespace (in the same nuget package - MilestoneSystems.VideoOS.Mobile.SDK).
The code for your Connect command should be something like:
var connectParams = new ConnectParams();
connectParams.PrimeLength = PrimeLength.Prime2048;
connectParams.EncodingPadding = EncodingPadding.Iso10126;
// persist this between commands
_encryption = new DHEncryption(connectParams.EncodingPadding, connectParams.PrimeLength);
string clientPublicKey = _encryption.GetPublicKey();
connectParams.PublicKey = clientPublicKey;
// send Connect command with already set connectParams
When you receive the response of the Connect command from the server, you should do something like:
// ServerPublicKey should be received on Connect response
_encryption.GenerateSecretKey(ServerPublicKey);
The code for the Login will be something like:
username = _encryption.Encrypt(username);
password = _encryption.Encrypt(password);
// send Login command with already encrypted username and password
Btw. DHKE algorithm used in the MoS protocol is standard. You could implement it by yourself (if you want). Just have to use prime modulus from the link.