Re: Encrypt in Perl and decrypt in JAVA
by moritz (Cardinal) on Jan 05, 2011 at 09:53 UTC
|
Many encryption methods are standardized, as well as some data interchange formats.
For example you could use Cypher block chaining with a common standard such as AES, and encode the result with base64, or percent encoding for URLs. Crypt::CBC would be your first choice on the Perl side, and I'm sure that Java also has pretty solid libraries for that.
| [reply] |
Re: Encrypt in Perl and decrypt in JAVA
by ELISHEVA (Prior) on Jan 05, 2011 at 09:47 UTC
|
Sure you can do it. It isn't a wild idea. Just make sure you use a compatible algorithm on each side. For the Perl/encryption side, you can find support for a variety of encryption algorithms/protocols at CPAN. For Java/decryption side, check the standard libraries or third party vendors.
| [reply] |
|
|
We tried with Crypt::CBC. In that I used the -cipher => 'blowfish' and got some hexa decimal code and passed that value in URL.
But, that value is not going to be decrypted at the java application.
They are just using some blowfish decryption algorithm.
| [reply] [d/l] |
|
|
They are just using some blowfish decryption algorithm.
Obviously you have to use the same algorithms and keys both in perl and java. That includes the same cypher block mode, the same key and data padding if the are of "wrong" size, and same content-encoding, if any.
If there's an existing java system which decrypts stuff, you first have to learn exactly what the java side does.
| [reply] |
|
|
| [reply] |
Re: Encrypt in Perl and decrypt in JAVA
by elagon (Initiate) on Jan 05, 2011 at 10:58 UTC
|
Remember to encode first the whole thing with base64 to be sure nothing get modified by the encoding/decoding in different languages | [reply] |
|
|
you mean to say that encode the string using base64, encrypt the encoded string, send , decrypt the string value and finally decode using base64?
| [reply] |
Re: Encrypt in Perl and decrypt in JAVA
by Anonymous Monk on Jan 05, 2011 at 09:54 UTC
|
Any idea on how this can be done?
- pick an algorithm (say AES)
- check to see if there are java/perl libraries for algorithm
- install libraries, read synopsis, adapt code, test it
- ...
- profit
| [reply] |
|
|
I have done something similar (php <-> perl).
I had problems with the binary data for some reason, and I solved my problems converting the data in base64 to pass it from/to php/perl
| [reply] |
Re: Encrypt in Perl and decrypt in JAVA
by suaveant (Parson) on Jan 05, 2011 at 14:55 UTC
|
I had something where I needed to have another group send me info crypted in the URL, I know they used a basic Java library for ECB Blowfish and the following line encrypted it propery, sorry I can't be more help, but maybe it can get you started.
Crypt::ECB::decrypt_hex( $key, 'Blowfish', $data, 1 );
- Ant
- Some of my
best work - (1 2 3)
| [reply] [d/l] |
Re: Encrypt in Perl and decrypt in JAVA
by locked_user sundialsvc4 (Abbot) on Jan 05, 2011 at 13:37 UTC
|
If it were me, I would use an AJAX-call to request the encrypted information. The JSON encoding system (say...) can handle any sort of data.
Also, remember that if the information is being handled on the user-side, it really isn’t “secret” at all. You really can’t keep secrets from the owner of the machine, if he seriously wants to know what they are. You can “obfuscate” them, but that’s about it.
You definitely need to use an industry-standard algorithm and it should probably use public-key encryption. However, the very best place to do any serious encryption, of anything that really needs protection, is in the communications hardware ... i.e. with VPN. If you know that you are talking through an encrypted channel, you can “speak plainly” and not be understood.
| |
Re: Encrypt in Perl and decrypt in JAVA
by Anonymous Monk on Feb 23, 2012 at 19:30 UTC
|
Was googling to find a way to do symmetric key encryption/decryption between Perl and Java. I was surprised that I could not find any working examples. I am replying here because this was the most recent search result.
I finally got it working using AES. If anyone is interested in the code I can post it. Turns out that I will not be using it =(
JamesUSC | [reply] |
|
|
Hi Anonymous monk,
Could you please post the code.
Thanks!
| [reply] |