Encode the URL parameter values

Encode the URL parameter values

  

Hey Guys,

I am in a need to encode my input parameter values when i pass the values to another page.

Consider that,

I have a list page and a detail page.

The detail page have a input parameter (For Ex : Person Id)


so in URL it will displayed as

https:......./module/detailscreen.aspz?PersonId=25468.


I need to encode the Parameter value. I tried in - build function EncodeURL(), But its not working.

Any Suggestion?


Thanks,

Keerthi


When your purpose is to disable the ability for the user to guess the next/previous user-id, you could add an extra column in your table where you store a UUID and pass that as parameter (and lookup use the UUID to lookup the expected user).

using encodeURL on integer or longinteger will give same output. 

Hi


encodeURL will not fit your purpose as it will only "translate" , for example, strings like "encode the url" into "encode+the+url", that's why it doesn't do anything with integers/ids.


I'd recommend to user CryptoAPI from the forge. https://www.outsystems.com/forge/Component_Details.aspx?ProjectId=437

This extension has a pair of methods, DecryptAES256 and EncryptAES256, that encodes and decodes the id into an encrypted string to be used instead of the Identifier in this case.


Gabriel

Hi Keerthi,

Just to add to Joost answer. On system you have a action called GenerateGuid. You can add this unique identifier to the new column of person and pass this GUID has a parameter.

Regards,

Marcelo

Gabriel Cardoso wrote:

Hi


encodeURL will not fit your purpose as it will only "translate" , for example, strings like "encode the url" into "encode+the+url", that's why it doesn't do anything with integers/ids.


I'd recommend to user CryptoAPI from the forge. https://www.outsystems.com/forge/Component_Details.aspx?ProjectId=437

This extension has a pair of methods, DecryptAES256 and EncryptAES256, that encodes and decodes the id into an encrypted string to be used instead of the Identifier in this case.


Gabriel

I tried using that component,

I used encrypt for my person id

PersonId=dCoHB/S5q9yJeD+KTCVwOqUyq0kLLdWdcZ1B+7tOJekLdsPbyOb4xYihhd0Fc1YPShXbqV+Ld+2dN6+X4QS/IQ==


while decrypt it retuns a error 

Invalid length for a Base-64 char array or string


Need to do any extra conversion during decrypt?

Marcelo Ferreira wrote:

Hi Keerthi,

Just to add to Joost answer. On system you have a action called GenerateGuid. You can add this unique identifier to the new column of person and pass this GUID has a parameter.

Regards,

Marcelo


Hey Marcelo,


Thanks for that suggestion. But i am trying the crypto API suggested by gabriel. If i cant able to achieve.

I will use the guid option.


Thanks,

Keerthi

Solution

Could you try 

Replace(EncryptedPersonId, " ", "+")

before calling DecryptAES256 action ? Input parameters with "+" sent throught url are converted into " " so you might have "dCoHB/S5q9yJeD KTCVwOqUy..." .

And are you using the same "Password" to encrypt / decrypt ?


EDIT: Use the Action "DecodeURL" from the "HTMLUtils" instead of the "Replace" Action 

Solution

Hey Gabriel,


Thanks for the solution

Both functions were working,

Replace() and DecodeURL().


But sometimes while using DecodeURL(), It returns the same error.

But Replace() function works in all terms.

So i prefer Replace().


Thanks,

Keerthi