private byte[] GetRsaPassword(string password, byte[] seedBytes, byte[] rawPublicKey)
        {
            if (password.Length == 0)
            {
                return(new byte[1]);
            }

            // Obfuscate the plain text password with the session scramble.
            byte[] obfuscated = GetXor(AliasText.Encoding.Default.GetBytes(password), seedBytes);

            // Encrypt the password and send it to the server.
#if NETSTANDARD1_3
            RSA rsa = MySqlPemReader.ConvertPemToRSAProvider(rawPublicKey);
            if (rsa == null)
            {
                throw new MySqlException(Resources.UnableToReadRSAKey);
            }
            return(rsa.Encrypt(obfuscated, RSAEncryptionPadding.OaepSHA1));
#else
            RSACryptoServiceProvider rsa = MySqlPemReader.ConvertPemToRSAProvider(rawPublicKey);
            if (rsa == null)
            {
                throw new MySqlException(Resources.UnableToReadRSAKey);
            }

            return(rsa.Encrypt(obfuscated, true));
#endif
        }
        private byte[] GetRsaPassword(string password, byte[] seedBytes, byte[] rawPublicKey)
        {
            if (password.Length == 0)
            {
                return(new byte[1]);
            }
            if (rawPubkey == null)
            {
                return(null);
            }
            // Obfuscate the plain text password with the session scramble.
            byte[] obfuscated = GetXor(Encoding.Default.GetBytes(password), seedBytes);

            // Encrypt the password and send it to the server.
            if (this.ServerVersion >= new Version("8.0.5"))
            {
                RSACryptoServiceProvider rsa = MySqlPemReader.ConvertPemToRSAProvider(rawPublicKey);
                if (rsa == null)
                {
                    throw new MySqlException(Resources.UnableToReadRSAKey);
                }

                return(rsa.Encrypt(obfuscated, true));
            }
            else
            {
                RSACryptoServiceProvider rsa = MySqlPemReader.ConvertPemToRSAProvider(rawPublicKey);
                if (rsa == null)
                {
                    throw new MySqlException(Resources.UnableToReadRSAKey);
                }

                return(rsa.Encrypt(obfuscated, false));
            }
        }