Encrypt crypted string in AC | Community
Skip to main content
Marcel_Szimonisz
New Participant
Oct 26, 2022 2:03 PM UTC
Solved

Encrypt crypted string in AC

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.
jorgeferreira
jorgeferreiraAccepted solution
Level 3
Sep 11, 2023 10:12 AM UTC

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.

 

10 replies

jorgeferreira
Level 3
Sep 8, 2023 10:06 AM UTC

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.

 

Translate
Sukrity_Wadhwa
Employee
Nov 9, 2022 7:29 AM UTC

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!

Translate
Sukrity Wadhwa
Marcel_Szimonisz
New Participant
Sep 11, 2023 9:54 AM UTC

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

Translate
jorgeferreira
jorgeferreiraAccepted solution
Level 3
Sep 11, 2023 10:12 AM UTC

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.

 

Translate
_Manoj_Kumar_
New Participant
Oct 27, 2022 5:22 AM UTC

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

Translate
     Manoj     Find me on LinkedIn
Marcel_Szimonisz
New Participant
Oct 27, 2022 6:08 AM UTC

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

Translate
_Manoj_Kumar_
New Participant
Oct 27, 2022 6:47 AM UTC

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.

 

Translate
     Manoj     Find me on LinkedIn