• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

encoding in java and decoding in perl

 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm running into problem when I'm trying to use AES to encrypt and encode some string and send to another server where there is perl program running which will decode and decrypt it.

I used base 64 encoding in Java and decode it in perl. But it looks like the string get coded does not match between java and perl. How should I solve this problem?

Plus, even after encoding/decoding is working, will perl recognize java's byte array as encrypted value?

Thanks.
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's no "recognition": the server side will either work or not--as long as the data coming in matches whatever format the Perl code is expecting.

As to what your actual problem is--AES is AES, regardless of the platform. Without knowing anything more about how the encryption/decryption is happening, how you're sending the data, etc. it's really difficult to help.
 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is my code in java:



here is the code in perl:


where I hardcoded value for $a_str, which is generated from java. But $de_base64 prints out some corrupted characters....
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You've left out some important information, but okay.

Is the value of $a_str in your Perl the value of the Base64-encoded, AES-encrypted output from the Java code?
 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:You've left out some important information, but okay.

Is the value of $a_str in your Perl the value of the Base64-encoded, AES-encrypted output from the Java code?



yes, it is. It's the value from that java method.
That Base64 class is imported from com.sun.org.apache.xerces.internal.impl.dv.util.Base64;


Here is the code I continue with the hardcoded value:


The last line of code causes an error: Ciphertext does not begin with a valid header for 'salt' header mode at ./aes.pl line 26

Is there any setting I did wrong for AES between java and perl?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And when you AES decode the Base64-decoded string, *that's* when you see you're not getting the original string?
 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to decode it and then decrypt it, but it's not successful.
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic