Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Data encrypted with "cryptString" function cannot be decrypted on website using CryptoJS

Avatar

Avatar
Affirm 1
Level 1
rwei-mms-web
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile

Avatar
Affirm 1
Level 1
rwei-mms-web
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile
rwei-mms-web
Level 1

05-03-2020

Hi,

I'm trying to embed some encrypted data in links in email and then get the data decrypted when user arrives at the actual website. 

 

Here is what we use to encrypt the data in the Adobe Camapgin:

<%= cryptString('test','base-64-encoded-256bit-key',false) %> 

 

Then on the website, I'm using CryptoJS (https://cryptojs.gitbook.io/docs/) to decrypt the data and I haven't been able to get the decryption working...

 

According to the cryptString documentation, cryptString uses a zero IV? the key param of the function is base64 representation of the AES key (bytes), then it's a CBC, the padding isn't clear in the documentation. I assume that's NoPadding of CryptoJS?

 

Does anyone have any success experience doing this? Thanks!

 

Javascript code:

var iv = CryptoJS.enc.Hex.parse("00000000000000000000000000000000");
var key = CryptoJS.enc.Base64.parse("base64-string-goes-here");
var decrypted = CryptoJS.AES.decrypt({
ciphertext: CryptoJS.enc.Base64.parse("output-of-cryptString"),
}, key, {
mode: CryptoJS.mode.CBC,
iv,
padding: CryptoJS.pad.NoPadding
});

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 1
Level 1
rwei-mms-web
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile

Avatar
Affirm 1
Level 1
rwei-mms-web
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile
rwei-mms-web
Level 1

07-03-2020

We ended up importing CryptoJS into ACC and use it directly there. Now we have full control on how AES is done and it works great so far.

Answers (2)

Answers (2)

Avatar

Avatar
Give Back
Level 2
CedricRey
Level 2

Likes

9 likes

Total Posts

21 posts

Correct Reply

4 solutions
Top badges earned
Give Back
Boost 5
Affirm 1
Establish
Boost 3
View profile

Avatar
Give Back
Level 2
CedricRey
Level 2

Likes

9 likes

Total Posts

21 posts

Correct Reply

4 solutions
Top badges earned
Give Back
Boost 5
Affirm 1
Establish
Boost 3
View profile
CedricRey
Level 2

30-04-2021

Hello,

I know your post is a year old, but I managed to get some result with the cryptString function.

First and as you mentionned, the key must be passed in base 64 format.

The salt parameter must be set to false.

Also, the result of the cryptString starts with the '@' character. When I try to decrypt it on the web page "https://www.devglan.com/online-tools/aes-encryption-decryption" (with empty Initial Vector of course), the "@" character doesn't seem to be a problem (and works also without), but with CryptoJS, you must delete this '@'.

Here an example :

//Adobe Campaign JS CODE to crypt 'Hello my friend' with 'CF12D5998AE799C6' key :
var key = "CF12D5998AE799C6";
var mBuffer = new MemoryBuffer(); mBuffer.fromString(key);
var b64Key = mBuffer.toBase64();
logInfo(cryptString("Hello my friend",b64Key, false) ) ;
//display : @1EZr24+U+KslB6s+5HSqjw==

Try to decrypt on devglan.com page :

Mode : CBC

IV : empty

Key Size in Bits: 128

Secret Key : CF12D5998AE799C6

AES Decrypted String : SGVsbG8gbXkgZnJpZW5k

Decoded Plain Text : Hello my friend

 

CryptoJS Example:

var CryptoJS = require("crypto-js");
const cryptkey = CryptoJS.enc.Utf8.parse('CF12D5998AE799C6'); //The key used, in text format
crypted = "1EZr24+U+KslB6s+5HSqjw=="; //Notice that the '@' IS DELETED
var decrypt = CryptoJS.AES.decrypt( crypted, cryptkey, {
    iv: CryptoJS.enc.Hex.parse('00000000000000000000000000000000'),
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.Pkcs7
});
console.log("-- " + decrypt.toString(CryptoJS.enc.Utf8) + " --");
// display : -- Hello my friend --

 

Hope this could help.

 

Cédric

Avatar

Avatar
Affirm 1
Level 1
rwei-mms-web
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile

Avatar
Affirm 1
Level 1
rwei-mms-web
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

1 solution
Top badges earned
Affirm 1
View profile
rwei-mms-web
Level 1

05-03-2020

This is getting very interesting... one strange thing I found is that none of the test outputs I got for the cryptString function is a valid base64 string. have no clue what I'm missing here.