Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

crypto functions in apigee javascript policy

Hi,
 
What is the easiest way convert this nodejs code using the builtin crypto package into an Apigee policy (preferably javascript)
 

 

const crypto=require('crypto');
const value = "stringtohash";
const hash = crypto.createHash('sha256').update(value).digest('hex');
const salt = "somlargevaluerepresentingthesalt";
const pbkHash = crypto.pbkdf2Sync(value, salt, 100000, 32, 'sha256').toString('hex');

 

 
hash and pbkHash would be available as context variables for subsequent policies.
 
Thanks.
 
 
 
Solved Solved
0 4 522
1 ACCEPTED SOLUTION

The JS policy supports a crypto class, which, contrary to its name, does hashing. Read about it here.

There is no PBKDF2 available in the Apigee Javascript policy. 

What are you really trying to do?  I know what a PBKDF2 does.  I want to know why you are planning to use Apigee to invoke PBKDF2. Can you give me some broader context, and maybe we can explore options.

 

View solution in original post

4 REPLIES 4