I'm using EncryptAES256 to encrypt some data. Then an e-mail is send, with an activation link (with parameter the encrypted string). When I decrypt the string on the screen (of the activation link), I get an error as mentioned in the title.
I checked that the generated string, the string in the link and the string passed to the decrypt are all the same (btw, it ends with an "=").
Few days ago it worked, but now I only get this error.
I searched the internet, but could not find a solution for this perticular situaton.
"the string in the link and the string passed to the decrypt are all the same"
Are they the same as the string that was output by the encrypt function ?
Ricardo Silva wrote:
yes they are (at least... I checked the first 3 and the last 3 characters...)
Was just re-reading that you also verified that the generated string is the same.
Could you paste one string that's being generated and getting that error here?
from the encrypt:
link in e-mail:
passed to the decrypt:
d RH5IYMuEJ1n/GixDnRbifwDJ1 c5dBLrol/hjChHdj8H5mdbohyPwo0o09VWirgnXbJN6RPINkuSlcnBxGC1LFxlKATfnstoCptJF6OBI=
+++> I see now that the second character is changed from a "+" to a space???
Message:Invalid length for a Base-64 char array or string.Environment InformationeSpaceVer: 388 (Id=93783, PubId=116430, CompiledWith=9.1.300.0)RequestUrl: https://os-zakelijk-dev.ee.intern/ToonBuildings_Klant/ActivateAccount.aspx?Activate=d+RH5IYMuEJ1n/GixDnRbifwDJ1+c5dBLrol/hjChHdj8H5mdbohyPwo0o09VWirgnXbJN6RPINkuSlcnBxGC1LFxlKATfnstoCptJF6OBI= (Method: GET)AppDomain: /LM/W3SVC/1/ROOT/ToonBuildings_Klant-40-131243743034245634FilePath: F:\Applic\OutSystems\Platform Server\running\ToonBuildings_Klant\ActivateAccount.aspxLocale: en-USDateFormat: yyyy-MM-ddPID: 13856 ('w3wp', Started='11/23/2016 7:06:56 AM', Priv=747Mb, Virt=18291Mb)TID: 38Thread Name:.NET: 4.0.30319.42000Stack:Invalid length for a Base-64 char array or string. at ssToonBuildings_Klant.RssExtensionCryptoAPI.MssDecryptAES256(HeContext heContext, String inParamCiphertext, String inParamPassword, String& outParamPlaintext) at ssToonBuildings_Klant.Flows.FlowMainFlow.ScrnActivateAccount.Preparation(HeContext heContext) at ssToonBuildings_Klant.Flows.FlowMainFlow.ScrnActivateAccount.Page_Load(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
There you go.
That's your issue. The + is being dumped directly to the URL which means it will be converted to a space. This is just how URL encoding works.
I recommend that you EncodeUrl() the value when generating the URL, or that you use the platform's functionality to create links instead of doing it by hand. By using a Destination node the URL should be properly encoded.
ok, i'll try that and let you know if it works.
Thanks already for your help!
Hans Hol wrote:
The Encode part works!
I'm not sure about your other solution using the lplatform to make a link. Because the link is put in an e-mail and is fired from that e-mail, I'm not sure if this works. E.g. what to do with the different environments the link has to consider (otap). If you like you can inform me, but for now I'm happy with the other solution.