Encrypt crypted string in AC | Community
Skip to main content
Marcel_Szimonisz
Community Advisor
Community Advisor
October 26, 2022
Solved

Encrypt crypted string in AC

  • October 26, 2022
  • 3 replies
  • 2580 views

Hello All,

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

 

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

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by jorgeferreira

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.

 

3 replies

_Manoj_Kumar_
Community Advisor
Community Advisor
October 27, 2022

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 - 355831

     Manoj     Find me on LinkedIn
Marcel_Szimonisz
Community Advisor
Community Advisor
October 27, 2022

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

_Manoj_Kumar_
Community Advisor
Community Advisor
October 27, 2022

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
Sukrity_Wadhwa
Community Manager
Community Manager
November 9, 2022

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
Marcel_Szimonisz
Community Advisor
Community Advisor
September 11, 2023

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

jorgeferreira
jorgeferreiraAccepted solution
Level 3
September 11, 2023

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.

 

jorgeferreira
Level 3
September 8, 2023

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.