in reply to RSA encryption for (Ducth) iDeal payment
I'm not familiar with your exact problem, but I have worked a lot with perl and encryption. Since I don't have "Crypt::OpenSSL::RSA" installed, I used the openssl command. My documentation for openssl shows input from a file. ( Just a note, since non printable characters are very important in encryption/decryption I use a "|" before/after any printed results so I can see if any characters {carriage return, etc} are added. Any remember almost all encryption/decryption results are stated in bits, so be careful about wanting character results. )
As you can see we differ already in step 1 ( getting the SHA1 ). Your result may not be in printable hex format, and therefore you may be correct, but again I'm not familiar with the exact problem. If you have the openssl command on your system, try doing this manually to get the right answer and then implement the process using perl. Encryption is never easy!
#!/usr/local/bin/perl -w # # RSA_encryption_Ducth_iDeal_payment # use strict; use MIME::Base64 (); use Digest::SHA1 qw(sha1 sha1_hex sha1_base64); #use Crypt::OpenSSL::RSA; my $string = "0021232117891234AcquirerStatusRes2004-11-02T15:05:03.750 +ZSuccess"; print ("\n\|$string:$string| (",length($string),")\n\n"); open (CTX, ">", "./ctx") or die "Could not open: $! \n"; print CTX "$string"; close CTX; my $sha1 = qx|openssl dgst -sha1 ./ctx|; print ("\n\$sha1:|$sha1| (",length($string),")\n\n"); #SHA encryption my $ctx = Digest::SHA1->new; $ctx->add($string); my $digest = $ctx->digest; my $len = length($digest); print ("SHA-1 DIGEST:$digest.. ($len)\n\n"); #RSA-encryption over the digest #Base64 encoding: my $encoded = MIME::Base64::encode($digest); my $len1 = length($encoded); print ("ENCODE:$encoded ($len1)\n\n"); __END__ #The result has to be (172 chars): #db82/jpJRvKQKoiDvu33X0yoDAQpayJOaW2Y8zbR1qk1i3epvTXi+6g+QVBY93YzGv4w+ +Va+vL3uNmzyRjYsm2309d1CWFVsn5Mk24NLSvhYfwVHEpznyMqizALEVUNSoiSHRkZUDf +XowBAyLT/tQVGbuUuBj+TkblY826nRa7U=
"Well done is better than well said." - Benjamin Franklin
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: RSA encryption for (Ducth) iDeal payment
by Eric66 (Initiate) on May 06, 2011 at 07:30 UTC | |
by flexvault (Monsignor) on May 06, 2011 at 14:07 UTC | |
by flexvault (Monsignor) on May 06, 2011 at 15:03 UTC |