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 :
Small and medium business | Business Central, N...
Suggested answer

Encryption of a string that's greater than 215

(6) ShareShare
ReportReport
Posted on by 37
Hello. 

I am currently engaged in developing an extension for Business Central cloud runtime 10.0.
My objective is to ensure the security of sensitive customer data by encrypting it before transmitting it to an Azure Function. The function will then decrypt it and further encrypt it with PGP, as mandated by business requirements.

Prior to transmitting this sensitive data, I aim to encrypt it to maintain its security throughout the HTTP request process.

However, I've encountered a limitation with System.Encrypt, which is restricted to text[215], whereas the data I need to encrypt exceeds 10k characters.

I am seeking suggestions on how to do this without resorting to uploading the text to blob storage and retrieving it through an Azure Function.

Alternatively, if there is a method to perform PGP encryption within Business Central, that would also be a viable solution. However, since it's not an on-premise setup, utilizing .NET DLLs isn't doable, and I'd likely need to develop a custom implementation.

Any insights or recommendations would be greatly appreciated.
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    94,504 Super User 2025 Season 2 on at
    Encryption of a string that's greater than 215
    Hi, sorry, I haven't tried it, but I think you can try the integration of Azure Function and Logic Apps.
    Decrypt PGP Files Seamlessly with Azure Function and Azure Logic Apps
     
    Use Azure Functions with Dynamics 365 Business Central
     
     
    Hopefully other experts can give you better advice.
    Thanks.
    ZHU
  • M(-12060832-0 Profile Picture
    37 on at
    Encryption of a string that's greater than 215
    I semi figured out a way to get around the encryption limit of 215
     
    for i := 1 to StrLen(myTextToEncrypt) do begin
                if i = 215 then begin
                    tempStringList.Add(tempString);
                    tempString:= '';
                    i := 1;
                end
                else begin
                    if myTextToEncrypt= '' then begin
                        tempStringList.Add(tempString);
                        break;
                    end;
                    tempString+= myTextToEncrypt[1];
                    myTextToEncrypt:= DelStr(myTextToEncrypt, 1, 1)
                end;
     
            end;
            for i := 1 to tempStringList.Count do begin
                tempString:= EncryptText(tempStringList.Get(i));
                secondListOfText.Add(tempString);
            end;
            for i := 1 to secondListOfText.Count do begin
                tempvar2 := Decrypt(secondListOfText.Get(i));
                finalListOfStrings.Add(tempString);
            end;

    So what I did was split the original string up into lists of text[215] and by adding 1 char at a time to the new entry and then deleting that char
    from the original text, I'd end up with my original string seperated into X amount of text[215].
    Each iteration I think if the original string is empty to make sure that even if remaining text is less than 215 chars, 
    it will still complete and not alter the text.

    All that you'd have to do then was run through the list and encrypt each of them. They do however need to kept seperated until
    ​​​​​​​they've been decrypted again.


    This is an extremely hacky solution, and a desperate one. 
    It did however not work for me because seeing as we are using cloud Business Central I could not export the encryption key and niether do we know
    which encryption was used, so I could not decrypt it in a .net project, as far as I know. 

    Hope this may help someone in the future.
  • Ramesh Kumar Profile Picture
    7,523 Super User 2025 Season 2 on at
    Encryption of a string that's greater than 215
    Hi,
     
    Please find the below link which will help on the encryption
     
     
    Thanks
    Ramesh
     
    If this helped you, please check the box Does this answer your question?
     
  • Suggested answer
    Suresh Kulla Profile Picture
    50,241 Super User 2025 Season 2 on at
    Encryption of a string that's greater than 215
    May be other way is store the data in the Blob and then use GenerateHashas shown below for the InStream. Check sample code in codeunit 9510
     
    CryptographyManagement.GenerateHash(InStream, HashAlgorithmType::SHA1);
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    20,147 Super User 2025 Season 2 on at
    Encryption of a string that's greater than 215

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,907

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,169 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,977 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans