HTML5 export spams 'Condition "flushing" is true' - RSACryptoServiceProvider

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bobokox

Hi!

I’m working on a small game with a highscore list on a server. I’v used godots Crypto class to do the rsa encrpytion, but unfortunately it’s not supported for html exports in 3.5.1. I now switched everything to c# RSACryptoServiceProvider. It works fine in the engine, but in the html export it spams

at: flush (core/message_queue.cpp:257) - Condition "flushing" is true. tmp_js_export.js:369:18

over and over again.

Does anybody know what it’s caused by or can recommend me another RSA library?

thank you very much.

Here are the relevent parts of the code:

public void writeToplist(string data) {
		
		RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
        File publicKeyFile = new File();
        publicKeyFile.Open("res://content/keys/convertedPublic.xml", File.ModeFlags.Read);
        rsa.FromXmlString(publicKeyFile.GetAsText());
        publicKeyFile.Close();
		byte[] encrypted = rsa.Encrypt(Encoding.UTF8.GetBytes(data), false);
		
		writeRequestCompleted = false;
		HTTPRequest request = new HTTPRequest();
		AddChild(request);
		request.Connect("request_completed", this, "OnWriteRequestCompleted");
		request.Request(wUrl, null, true, HTTPClient.Method.Post, Convert.ToBase64String(encrypted));
		GD.Print("toplist written");
	}

	public void readToplist() {
		answer = null;
		HTTPRequest request = new HTTPRequest();
		AddChild(request);
		request.Connect("request_completed", this, "OnReadRequestCompleted");
		request.Request(rUrl);
	}

	private void OnReadRequestCompleted(long result, long responseCode, string[] headers, byte[] body)
    {
        if (result != (int)HTTPRequest.Result.Success)
        {
            GD.Print("HTTP request failed");
            answer = "Data not found.";
        }

    	answer = Encoding.UTF8.GetString(body);    
			
		RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
		File privateKeyFile = new File();
        privateKeyFile.Open("content/keys/convertedPrivate.xml", File.ModeFlags.Read);
        rsa.FromXmlString(privateKeyFile.GetAsText());
        privateKeyFile.Close();
        byte[] decrypted = rsa.Decrypt(Convert.FromBase64String(answer), false);
		

		answer = Encoding.UTF8.GetString(decrypted);
        
    }