web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

How to decrypt the encrypted string using RSA in D365 FO

(0) ShareShare
ReportReport
Posted on by 28
Hi All,
 
How to decrypt the encrypted string using RSA private key in D365 FO?
 
Thanks & Regards,
Masha
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    236,751 Most Valuable Professional on at
    How to decrypt the encrypted string using RSA in D365 FO
    I'm not aware of anything specific to F&O, but you can use .NET types in X++ (via .NET Interop). RSACryptoServiceProvider likely is what youůre looking for.
  • it.dev Profile Picture
    28 on at
    How to decrypt the encrypted string using RSA in D365 FO
    Hi Martin,
     
    i have check the documentation i a little bit confused in this decrypt method
    public static byte[] RSADecrypt(byte[] DataToDecrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding)
        {
            try
            {
                byte[] decryptedData;
                //Create a new instance of RSACryptoServiceProvider.
                using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider())
                {
                    //Import the RSA Key information. This needs
                    //to include the private key information.
                    RSA.ImportParameters(RSAKeyInfo);
    
                    //Decrypt the passed byte array and specify OAEP padding.  
                    //OAEP padding is only available on Microsoft Windows XP or
                    //later.  
                    decryptedData = RSA.Decrypt(DataToDecrypt, DoOAEPPadding);
                }
                return decryptedData;
            }
            //Catch and display a CryptographicException  
            //to the console.
            catch (CryptographicException e)
            {
                Console.WriteLine(e.ToString());
    
                return null;
            }
        }
    how to import the provided private key into this method?
     
    Thanks & Regards,
    Masha
  • Martin Dráb Profile Picture
    236,751 Most Valuable Professional on at
    How to decrypt the encrypted string using RSA in D365 FO
    If you look at the code, you'll notice that the key must be passed to the instance of RSACryptoServiceProvider. Your example uses ImportParameters(), but there are other methods too, such as ImportEncryptedPkcs8PrivateKey(). What exactly you should do depends on where you have the key.
     
    Note that we're now discussing pure C# code, not anything about F&O. Consider asking in a .NET forum, because there you'll reach more people experienced with such things then here.
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 753

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 752 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 534 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans