/// <summary> /// Login to Rserver /// </summary> /// <param name="user"> /// User name for the user /// </param> /// <param name="password"> /// Password for the user /// </param> /// <param name="method"> /// pt for plain text /// </param> /// <param name="salt"> /// The salt to use to encrypt the password /// </param> private void Login( string user , string password , string method , string salt = null ) { if ( user == null ) { throw new ArgumentNullException( "user" ); } if ( password == null ) { throw new ArgumentNullException( "password" ); } switch ( method ) { case "pt": _protocol.Command( CmdLogin , new object[] { user + "\n" + password } ); break; case "uc": password = new DES().Encrypt( password , salt ); _protocol.Command( CmdLogin , new object[] { user + "\n" + password } ); break; default: throw new ArgumentException( "Could not interpret login method '" + method + "'" ); } }
/// <summary> /// Login to Rserver /// </summary> /// <param name="user"> /// User name for the user /// </param> /// <param name="password"> /// Password for the user /// </param> /// <param name="method"> /// pt for plain text /// </param> /// <param name="salt"> /// The salt to use to encrypt the password /// </param> async Task LoginAsync(string user, string password, string method, string salt = null) { if (user == null) throw new ArgumentNullException(nameof(user)); if (password == null) throw new ArgumentNullException(nameof(password)); switch (method) { case "pt": await _protocol.CommandAsync(CmdLogin, new object[] { user + "\n" + password }) .ContinueContextFree(); break; case "uc": password = new DES().Encrypt(password, salt); await _protocol.CommandAsync(CmdLogin, new object[] { user + "\n" + password }) .ContinueContextFree(); break; default: throw new ArgumentException("Could not interpret login method '" + method + "'"); } }