Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How to decrypt the encrypted string using RSA in D365 FO

Posted on by 122
Hi All,
 
How to decrypt the encrypted string using RSA private key in D365 FO?
 
Thanks & Regards,
Masha
  • Martin Dráb Profile Picture
    Martin Dráb 230,149 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.
     
  • it.dev Profile Picture
    it.dev 122 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
  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 230,149 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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans