invoke java class

Hi,

I am trying to encrypt a number in a userForm.

I've got this so far: (using javax.crypto.Cipher)

<block trace='true'>

<set name='keygen'>

<invoke name='getInstance' class='javax.crypto.KeyGenerator'>

<s>DES</s>

</invoke>

</set>

<set name='desKey'>

<invoke name='generateKey'>

<ref>keygen</ref>

</invoke>

</set>

<set name='cleartext'>

<invoke name='getBytes'>

<s>This is just an example</s>

</invoke>

</set>

<set name='Cipher_Instance'>

<invoke name='getInstance' class='javax.crypto.Cipher'>

<s>DES/ECB/PKCS5Padding</s>

</invoke>

</set>

<set name='initialized_cipher'>

<invoke name='init'>

<ref>Cipher_Instance</ref>

<i>1</i>

<ref>desKey</ref>

</invoke>

</set>

<invoke name='doFinal'>

<ref>initialized_cipher</ref>

<ref>cleartext</ref>

</invoke>

</set>

</block>

In the log file i see that the initialized_cipher returns null:

<set name='initialized_cipher'>

<invoke name='init'>

<ref>Cipher_Instance</ref>Resolved Cipher_Instance to javax.crypto.Cipher@1a7335

--> javax.crypto.Cipher@1a7335

<i>1</i> --> 1

<ref>desKey</ref>Resolved desKey to com.sun.crypto.provider.DESKey@fffe7f69

--> com.sun.crypto.provider.DESKey@fffe7f69

</invoke> --> nullFormState.addOutput initialized_cipher = null

Set initialized_cipher to null

Any ideas anyone?

[2256 byte] By [tine_de_mik] at [2007-11-26 10:37:34]
# 1
I am curious to know have you defined the varaibles before you set ? Just wanted to check. sFred
sFred at 2007-7-7 2:48:37 > top of Java-index,Web & Directory Servers,Directory Servers...
# 2

it looks like .init() is a void function... It is returning null. perhaps you

try to get the value of CIpher_Instance. I bet that may variable will contain the encrytped vlue you are looking for....or some get() function may have to be called to get the value...Cipher_Instance.getValue() perhaps?

Dana Reed

AegisUSA

danareed at 2007-7-7 2:48:37 > top of Java-index,Web & Directory Servers,Directory Servers...