Skip to content

Whenever I try to use RSA Encryption it throws a XmlSyntaxException: System error #7

Description

@peq42

Using Unity 2021.3.16f1 LTS. Here's my code:

        string name=textfield.text;
        string password=textfieldpass.text;
        name=name.Remove(name.Length - 1, 1);
        password=password.Remove(password.Length - 1, 1);
        if(name=="") return;
        GameObject.Find("sendtext").GetComponent<TMP_Text>().text="Sending...";

        string plainText = (name+"&&."+password+"&&."+double.Parse(PlayerPrefs.GetString("followercounter")).ToString("N0").Replace(".", ""));
        string encrypted = RSAEncryption.Encrypt(plainText,"-----BEGIN PUBLIC KEY-----
massive public key
-----END PUBLIC KEY-----" );
        Debug.Log(encrypted);

        StartCoroutine(GetRequest("https://www.peq42.com/highscore?"+encrypted));

Error thrown when I try to run it:

XmlSyntaxException: System error.
System.Security.Util.Parser.GetRequiredSizes (System.Security.Util.TokenizerStream stream, System.Int32& index) (at <75633565436c42f0a6426b33f0132ade>:0)
System.Security.Util.Parser.ParseContents () (at <75633565436c42f0a6426b33f0132ade>:0)
System.Security.Util.Parser..ctor (System.Security.Util.Tokenizer t) (at <75633565436c42f0a6426b33f0132ade>:0)
System.Security.Util.Parser..ctor (System.String input) (at <75633565436c42f0a6426b33f0132ade>:0)
System.Security.Cryptography.RSA.FromXmlString (System.String xmlString) (at <75633565436c42f0a6426b33f0132ade>:0)
UnityCipher.RSAEncryption.Encrypt (System.Byte[] src, System.String publicKey) (at Assets/Scripts/minorscripts/RSAEncryption.cs:30)
UnityCipher.RSAEncryption.Encrypt (System.String plain, System.String publicKey) (at Assets/Scripts/minorscripts/RSAEncryption.cs:21)
scoresubmit.sendScore () (at Assets/Scripts/minorscripts/scoresubmit.cs:28)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions