Hi all,
I have a .jar file to be call the in my perl module.
Which is used to calculate 3DES/RSA encryption of password.
The .jar file (ChunghwaPost.jar) was archived like this.
url: https://ipost.post.gov.tw/web/ChunghwaPost.jar
file: MainApplet.class
file: MainApplet.html
Directory and files: PaySecure.*
MainApplet.class is the integrated interface of class PaySecure.
MainApplet.html is the demo of how to use MainApplet.class
So here is the java code which embedded in the MainApplet.html.
The order of function execution to encrypt password is
GenTDES()->EncryptTDES()->RSAEncryptTDES();.
In other words, the actual calling order which mapped into .jar file is
Generate3DES()->getEncryptPINcode()->getRsaEncrypt3DES();.
function GenTDES() // Generate3DES() can be direct accessed in MainApp +let.class { if(document.app.Generate3DES()) { document.form1.GetGenTDESVle.value= "Success"; } else { document.form1.GetGenTDESVle.value=document.app.getErrorString(); } } // getEncryptPINcode() can be direct accessed in MainApplet.class function EncryptTDES() { if(document.app.EncryptPINcode(document.form1.UserPin.value)) { document.form1.GetEncryptTDESVle.value= document.app.getEn +cryptPINcode(); } else { document.form1.GetEncryptTDESVle.value=document.app.getErr +orString(); } } // RsaEncrypt3DES() can be direct accessed in MainApplet.class however + it will call into PaySecure.* classes. function RSAEncryptTDES() { if(document.app.RsaEncrypt3DES()) { document.form1.GetRSAEncryptTDESVle.value= document.app.getRsaEn +crypt3DES(); } else { document.form1.GetRSAEncryptTDESVle.value= document.app.getError +String(); } }
package POST_jCRYPT; use strict; use warnings; use Inline::Java; BEGIN { $ENV{CLASSPATH} .= "./ChunghwaPost.jar"; } use Inline Java => 'STUDY', STUDY => [ 'MainApplet' ], AUTOSTUDY => '1', DEBUG => '1'; sub new { my $MainApplet = shift; return POST_jCRYPT->new(@_); } 1;
#!/usr/bin/perl #use strict; use warnings; use Inline::Java; use Data::Dumper; use lib '/home/macpaul/perl'; use POST_jCRYPT; my $pwd ="12345678"; my $usercode ="example1"; my $javaobj = POST_jCRYPT::MainApplet->new(); # ePin print $javaobj->Generate3DES(), "\n"; $javaobj->EncryptPINcode($pwd); my $ePIN = $javaobj->getEncryptPINcode(); print $ePIN, "\n"; $javaobj->RsaEncrypt3DES(); my $eKey = $javaobj->getRsaEncrypt3DES(); print $eKey, "\n";
However, when I execute jartest.pl, I can get correct result when I called "Generate3DES()" and "getEncryptPINcode()", but fail when "getRsaEncrypt3DES" and I get "method RsaEncrypt3DES in class MainApplet threw exception java.lang.NullPointerException: null".
Any misteak I have made so that I couldn't get the same result when I do this encryption by opening the demo html in browser?
Thanks for help.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |