How To Import Crypto.Cipher AES Module Python Policy ?

I am trying to use AES GCM Algorithm to decrypt  some data, when I am running this python script on APIGEE

Getting Error --> ImportError: No module named Crypto

 

How can I import this module to Apigee ? 

I tried to use command line but it dose not work with me 

Solved Solved
0 3 2,356
1 ACCEPTED SOLUTION

source must specify the name of a context variable.

Not a hard-coded ciphertext. 

To use this callout, you must have a context variable that contains the ciphertext. 

Check the README for details and examples.

 

View solution in original post

3 REPLIES 3

The Python you can use in a Java callout is actually Jython, which implies it's an older Python engine and some of the modules available in current Python may not be available in the Jython layer. 

Two suggestions for you.

  • use an external callout. This works if you have Apigee X, OR
  • use the AES callout built in Java.  Available here

Good luck! 

Thanks very helpful ,, 

I am tying to use it now but I am facing a problem which is when I specify all properties it gives me Error 500  :

java.lang.IllegalStateException: missing source at com.google.apigee.callouts.AesCryptoCallout.getSourceBytes(AesCryptoCallout.java:331) at com.google.apigee.callouts.AesCryptoCallout.execute(AesCryptoCallout.java:396) at

java.lang.IllegalStateException: missing source

 

JavaCallOut Body:

<Properties>
<Property name="action">decrypt</Property>
<Property name="debug">true</Property>
<Property name="mode">GCM</Property>
<Property name="padding">NoPadding</Property>
<Property name="key">385f9fd4cba017c159956276036545b0</Property>
<Property name="decode-key">base16</Property>
<Property name="iv">mRqogt0pxtPdgyjt</Property>
<Property name="decode-iv">base64url</Property>
<Property name="source">73XlhsvhcsaIFJUrqZFyf0Hjgxx9A-rbPWoIdsup-ScsXuqO6RevhNdjBg</Property>
<Property name="decode-source">base64url</Property>
<Property name="aad">eyJ0eXAiOiJKV1QiLCJoZHIxIjoxMjMsImVuYyI6IkExMjhHQ00iLCJoZHIyIjp0cnVlLCJhbGciOiJSU0EtT0FFUC0yNTYifQ</Property>
<Property name="tag">ESdhCa_eqd2FaI5e5IH2xQ</Property>
<Property name="decode-tag">base64url</Property>
<Property name="utf8-decode-result">true</Property>
</Properties>
<ClassName>com.google.apigee.callouts.AesCryptoCallout</ClassName>
<ResourceURL>java://apigee-callout-aes-crypto-20211122a.jar</ResourceURL>
</JavaCallout>

source must specify the name of a context variable.

Not a hard-coded ciphertext. 

To use this callout, you must have a context variable that contains the ciphertext. 

Check the README for details and examples.