Problem getting HmacSHA512 with CryptoJS to work

Simon Larsson
Tera Contributor

Hello,

I've tried to implement some variant of CryptoJS for making an authentication token. The problem is when i run the code snippet below I encounter this error:

Evaluator.evaluateString() problem: java.lang.SecurityException: Encountered scriptable of unknown type Object

 

var key = "sample_key"; 
var secret = CryptoJS.enc.Base64.parse(key);
var str = CryptoJS.HmacSHA512("sample_data", secret);
str = CryptoJS.enc.Base64.stringify(str);

I think the error is occuring when trying to create the HmacSHA512 encoding. The code works fine running in a node.js environment.
I have created a Script Include called CryptoJS with the code attached in the file.
find_real_file.png

Anyone have some experience working with HmacSHA512, any help is appriciated.

1 ACCEPTED SOLUTION

Not sure why that is. However I'll attach your file modified by me as described; I've tested it in both San Diego and Quebec. I assume if it works in those two, it should also work in Rome.

View solution in original post

11 REPLIES 11

Niclas
Giga Guru

There is actually an out of box method for that, it's  CertificateEncryption generateMac. 

 

Also may have a look into Configure Custom Authentication Algorithm

 

I've tried this but it's not working since i need a wordarray to create the token and not a base64 encoded string. This would otherwise work well.