Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!
SOLVED

Encrypt crypted string in AC

Avatar

Community Advisor

Hello All,

I cannot find function in JSAPI that encrypts string with key all the functions for this are deprecated

Marcel_Szimonisz_0-1666792914905.png

 

decryptPassword() how that works you do not provide any key to it.

Do we have more information around this topic?

I need to decrypt encrypted query parameters by AEM

 

Marcel

 

1 Accepted Solution

Avatar

Correct answer by
Level 3

Hey, 

 

Indeed, says deprecated but works normally (build 9359).

The test I've made:

 

Instance 1:

 

var firstName = 'John'
var lastName = 'Doe'
var language = 'NL'
var email = 'john.doe@gmail.com';
var key = 'abcdefghijklmnopqrstuvwx12345678'; // key with 32 bytes

logInfo('email= '+cryptString(email, key);
logInfo('firstName= '+cryptString(firstName, key);
logInfo('lastName= '+cryptString(lastName, key);

 

 

Result:

lastName= @kwVuNfze15Wy1FYoXboEvQ==
irstName= @HT2m15epsQxgzTPoWnDzgw==
email= @vVyMeUIZPeQkNJ5rVvMJV8ooQvxuHXmZQRNHa9612qM=

 

Instance 2:

var key = 'abcdefghijklmnopqrstuvwx12345678'; // key with 32 bytes
var firstName = "@HT2m15epsQxgzTPoWnDzgw=="
var lastName = "@kwVuNfze15Wy1FYoXboEvQ=="
var email = "@vVyMeUIZPeQkNJ5rVvMJV8ooQvxuHXmZQRNHa9612qM="


logInfo("email: " + decryptString(email, key));
logInfo("firstName: " + decryptString(firstName, key));
logInfo("lastName: " + decryptString(lastName, key));

 

result:

firstName: John
lastName: Doe
cemail: john.doe@gmail.com

 

I used 2 instances to eliminate any possibility of the function using the instance ID as key.

 

View solution in original post

10 Replies

Avatar

Community Advisor

Hello @Marcel_Szimonisz 

 

You can use the CryptoJS library to encrypt and decrypt the data.

 

The sample code is shared by @CedricRey on this thread.

Solved: Re: Data encrypted with "cryptString" function can... - Adobe Experience League Community - ...


     Manoj
     Find me on LinkedIn

Avatar

Community Advisor

Hello @Manoj_Kumar_ ,

crypto js is it compatible with the adobe's JSSP ? so basically I need to find external library to crypt decrypt strings that is compatible with Adobe JSSP

Avatar

Community Advisor

Hello @Marcel_Szimonisz 

Yes, that seems to be the only way, because decrpyString is not deprecated.

 

Also, decryptPassword is used to decrypt the password for external accounts.

So, if you are looking to encrypt and decrypt anything other than passwords then you will have to rely on an external library.

 


     Manoj
     Find me on LinkedIn

Avatar

Employee Advisor

Hi @Marcel_Szimonisz 

 

Unless I'm wrong the JSAPI function cryptStrig is still available

https://experienceleague.adobe.com/developer/campaign-api/api/f-cryptString.html?hl=encrypt

and @Manoj_Kumar_ shared a sample from Cedric that uses the cryptString...

Saying that, any reason why you would want to encrypt a string already crypted?

I always find encrypting / decrypting very hard to nail down between system due to the sensitivity of the underlying libraries used by each system, ACC uses JavaScrupt and you might need to decrypt using Java or .Net or php or JavaScript, you will spend hours to nail down and align the encryption with the decryption..

try cryptString mentioned above.

Thanks

Denis

Avatar

Community Advisor

Hello @Denis_Bozonnet ,
How do I decrypt such encrypted link in JSSP. I was trying to find new version for 
https://experienceleague.adobe.com/developer/campaign-api/api/f-decryptString.html

Thanks a lot for your help
Marcel

Avatar

Community Advisor

Hello @Denis_Bozonnet,

I wanted to encrypt query parameters on AEM side and then descrypt on Adobe Campaign side on landing lage.

Marcel

Avatar

Administrator

Hi @Marcel_Szimonisz,

Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!



Sukrity Wadhwa

Avatar

Community Advisor

Hello @jorgeferreira ,

but how do i decrypt crypted string decrypt function is deprecated.. i suppose it is deprecated but it works.. i will need to check it myself. thanks a lot

Marcel

Avatar

Correct answer by
Level 3

Hey, 

 

Indeed, says deprecated but works normally (build 9359).

The test I've made:

 

Instance 1:

 

var firstName = 'John'
var lastName = 'Doe'
var language = 'NL'
var email = 'john.doe@gmail.com';
var key = 'abcdefghijklmnopqrstuvwx12345678'; // key with 32 bytes

logInfo('email= '+cryptString(email, key);
logInfo('firstName= '+cryptString(firstName, key);
logInfo('lastName= '+cryptString(lastName, key);

 

 

Result:

lastName= @kwVuNfze15Wy1FYoXboEvQ==
irstName= @HT2m15epsQxgzTPoWnDzgw==
email= @vVyMeUIZPeQkNJ5rVvMJV8ooQvxuHXmZQRNHa9612qM=

 

Instance 2:

var key = 'abcdefghijklmnopqrstuvwx12345678'; // key with 32 bytes
var firstName = "@HT2m15epsQxgzTPoWnDzgw=="
var lastName = "@kwVuNfze15Wy1FYoXboEvQ=="
var email = "@vVyMeUIZPeQkNJ5rVvMJV8ooQvxuHXmZQRNHa9612qM="


logInfo("email: " + decryptString(email, key));
logInfo("firstName: " + decryptString(firstName, key));
logInfo("lastName: " + decryptString(lastName, key));

 

result:

firstName: John
lastName: Doe
cemail: john.doe@gmail.com

 

I used 2 instances to eliminate any possibility of the function using the instance ID as key.

 

Avatar

Level 3

Hello Marcel, 

 

I have been through some rough terrains with cryptString and decryptString as well.

For your specific question, I assume decryptPassword only works for external accounts because the key is the instanceID. 

If you check the doc on cryptString, one of the remarks is:

  • This string is encrypted using the AES algorythm in Cipher Block Chaining (CBC) mode with a null initialization vector. If no key is provided as a parameter, the instance key is used.