How to add CryptoJS in apigee ?

Not applicable

We want to use message level encryption on apiKey when sending the information to target servers. While sending the apiKey over to target servers we want to encrypt (with hmac) and send it to them. In order to achieve this, we tried via CryptoJS

. Can you please let us know the best easy way to achieve this?

0 7 684
7 REPLIES 7

Are talking about using CryptoJS in a javascript policy scenario? It is hard to say, what you did wrong without your providing any information about what you've tried.

The CryptoJS lib works as you'd expect it to without any additional tricks.

Here is a way to implement 3DES encryption.

1. Create a JavaScript policy that references crypt-js.js library and necessary components.

4304-screen-shot-2017-02-06-at-103203.png

2. Write required javascript code.

4305-screen-shot-2017-02-06-at-103320.png

3. Use the policy in a flow.

Not applicable

1.) Import the script to Apigee, then in your Javascript policy Include it like this,



<IncludeURL>jsc://crypto-js.js</IncludeURL>
<ResourceURL>jsc://encrypt-apikey.js</ResourceURL>


2.) In your encrypt-apikey.js script, you can encrypt the key like this

var encrypted_apikey = CryptoJS.HmacSHA1(apikey, "encrypt-key").toString()
context.setVariable('encrypted_apikey',encrypted_apikey)

So. What is an error and/or output?

Not seeing any issue, It worked @ylesyuk1

Not applicable

@ylesyuk1, Could you please share cryptojs.js file?

Regards,

Nagesh

Not applicable
@Madhumita Kumari

Could you please share the proxy bundle along with js libs?

Thanks in advance!

REgards,

Nagesh