Important information regarding COVID-19. Please click here immediately.
Results 1 to 5 of 5
  1. #1
    JustWorkHereLUL's Avatar
    Join Date
    Nov 2017
    Gender
    male
    Posts
    181
    Reputation
    10
    Thanks
    2
    My Mood
    Angry

    Post RSA encrypting and decrypting

    Hey! I'm trying to make a function that takes a public key and text to format as parameters, both as strings. I'm trying to log in to steam via post requests and have to pass in the password encrypted with RSA key gotten from steam. I can get the key from steam fine as string but I cannot find a working way to use the key to encrypt the password.

  2. #2
    defaulto's Avatar
    Join Date
    Aug 2017
    Gender
    male
    Posts
    458
    Reputation
    349
    Thanks
    274
    My Mood
    Angelic
    I haven't worked yet with RSA. The concept seems to be interesting though. So. After googleing it, I guess, this is what you are looking for:
    Code:
    public static string Encryption(string strText)
            {
                var publicKey = "<RSAKeyValue><Modulus>21wEnTU+mcD2w0Lfo1Gv4rtcSWsQJQTNa6gio05AOkV/Er9w3Y13Ddo5wGtjJ19402S71HUeN0vbKILLJdRSES5MHSdJPSVrOqdrll/vLXxDxWs/U0UT1c8u6k/Ogx9hTtZxYwoeYqdhDblof3E75d9n2F0Zvf6iTb4cI7j6fMs=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
    
                var testData = Encoding.UTF8.GetBytes(strText);
    
                using (var rsa = new RSACryptoServiceProvider(1024))
                {
                    try
                    {
                        // client encrypting data with public key issued by server                    
                        rsa.FromXmlString(publicKey.ToString());
    
                        var encryptedData = rsa.Encrypt(testData, true);
    
                        var base64Encrypted = Convert.ToBase64String(encryptedData);
    
                        return base64Encrypted;
                    }
                    finally
                    {
                        rsa.PersistKeyInCsp = false;
                    }
                }
            }
    
    
    Source: https://stackoverflow.com/questions/17128038/c-sharp-rsa-encryption-decryption-with-transmission
    Last edited by defaulto; 07-02-2019 at 02:01 PM.

    #LOGS
    12-02-2020 ⌨ [MPGH]defaulto got gifted the Premium Membership from [MPGH]Azuki - sponsored by [MPGH]Flengo.
    27-11-2019 ⌨ [MPGH]defaulto captured the GFX Team Base together with [MPGH]Howl & [MPGH]Poonce.
    08-14-2017 ⌨ defaulto joined the game.

  3. The Following User Says Thank You to defaulto For This Useful Post:

    MikeRohsoft (07-03-2019)

  4. #3
    JustWorkHereLUL's Avatar
    Join Date
    Nov 2017
    Gender
    male
    Posts
    181
    Reputation
    10
    Thanks
    2
    My Mood
    Angry
    Quote Originally Posted by defaulto View Post
    I haven't worked yet with RSA. The concept seems to be interesting though. So. After googleing it, I guess, this is what you are looking for:
    Code:
    public static string Encryption(string strText)
            {
                var publicKey = "<RSAKeyValue><Modulus>21wEnTU+mcD2w0Lfo1Gv4rtcSWsQJQTNa6gio05AOkV/Er9w3Y13Ddo5wGtjJ19402S71HUeN0vbKILLJdRSES5MHSdJPSVrOqdrll/vLXxDxWs/U0UT1c8u6k/Ogx9hTtZxYwoeYqdhDblof3E75d9n2F0Zvf6iTb4cI7j6fMs=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
    
                var testData = Encoding.UTF8.GetBytes(strText);
    
                using (var rsa = new RSACryptoServiceProvider(1024))
                {
                    try
                    {
                        // client encrypting data with public key issued by server                    
                        rsa.FromXmlString(publicKey.ToString());
    
                        var encryptedData = rsa.Encrypt(testData, true);
    
                        var base64Encrypted = Convert.ToBase64String(encryptedData);
    
                        return base64Encrypted;
                    }
                    finally
                    {
                        rsa.PersistKeyInCsp = false;
                    }
                }
            }
    
    
    Source: https://stackoverflow.com/questions/17128038/c-sharp-rsa-encryption-decryption-with-transmission
    It's giving me some errors:

    x64: Unhandled Exception: System.PlatformNotSupportedException: Operation is not supported on this platform.
    x86: Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'C:\Users\makez\source\repos\RSA\RSA\bin\x86\Relea se\netcoreapp2.1\RSA.dll'. An attempt was made to load a program with an incorrect format.

    (In build settings application type is set to console application)

  5. #4
    defaulto's Avatar
    Join Date
    Aug 2017
    Gender
    male
    Posts
    458
    Reputation
    349
    Thanks
    274
    My Mood
    Angelic
    Quote Originally Posted by JustWorkHereLUL View Post
    It's giving me some errors:

    x64: Unhandled Exception: System.PlatformNotSupportedException: Operation is not supported on this platform.
    x86: Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'C:\Users\makez\source\repos\RSA\RSA\bin\x86\Relea se\netcoreapp2.1\RSA.dll'. An attempt was made to load a program with an incorrect format.

    (In build settings application type is set to console application)
    Wait I give it a try myself. Will edit this reply when I got it working.
    Did you downloaded something extra? It should be already included in the .NET Framework, which can be used by "using System.Security.Cryptography;".
    Is NET Core actually the same as the NET Framework?

    #LOGS
    12-02-2020 ⌨ [MPGH]defaulto got gifted the Premium Membership from [MPGH]Azuki - sponsored by [MPGH]Flengo.
    27-11-2019 ⌨ [MPGH]defaulto captured the GFX Team Base together with [MPGH]Howl & [MPGH]Poonce.
    08-14-2017 ⌨ defaulto joined the game.

  6. #5
    JustWorkHereLUL's Avatar
    Join Date
    Nov 2017
    Gender
    male
    Posts
    181
    Reputation
    10
    Thanks
    2
    My Mood
    Angry
    Quote Originally Posted by defaulto View Post
    Is NET Core actually the same as the NET Framework?
    Ah damn I accidently had made .NET Core console application instead of .NET Framework, works now!

Similar Threads

  1. [Help Request] Encrypt Passwords in MySQL to access and decrypt in GUI
    By SomeAsianDude in forum Java
    Replies: 1
    Last Post: 11-13-2018, 02:17 PM
  2. [Unresolved] Encryption and Decryption, error
    By Ryan28 in forum C# Programming
    Replies: 3
    Last Post: 01-24-2017, 10:38 AM
  3. [WTS] Script Encrypting and Decrypting Service
    By ikillindreams in forum DayZ Selling / Trading / Buying
    Replies: 1
    Last Post: 02-01-2013, 11:18 PM
  4. [Source Code] Text Encrypter and Decrypter
    By rileyjstrickland in forum Visual Basic Programming
    Replies: 3
    Last Post: 11-09-2012, 08:32 PM
  5. [Help Request] Error Elite Encrypt.. and no hacks work.
    By 48Aces in forum Combat Arms Help
    Replies: 4
    Last Post: 09-08-2011, 10:23 AM

Tags for this Thread