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

Announcements

No record found.

News and Announcements icon
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 30
Hi All,
 
How to decrypt the encrypted string using RSA private key in D365 FO?
 
Thanks & Regards,
Masha
  • Suggested answer
    Martin Dráb Profile Picture
    241,469 Most Valuable Professional on at
    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
    30 on at
    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
    241,469 Most Valuable Professional on at
    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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
Martin Dráb Profile Picture

Martin Dráb 539 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 366 Super User 2026 Season 2

#3
CU-1234529-002 Profile Picture

CU-1234529-002 197

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans