0

Here is the problem I am facing. There is a mechanism running on Server A (that is IBM i740 main frame) that takes secure data and uses AES to encrypt it. Now I, I want to get that ENCRYPTED data (AES encrypted string), but since it uses garbled characters, it can't be transmitted over http. So in order for me to get it, there is a web service exposed that finds that AES encrypted string, HEX'es and returns me a HEX string, like F51A751CC72124EE95518BECBA1F47C4. My question is, is there any way for me to convert (preferably, in Java) that HEX value back to AES encrypted string (I DON'T WANT TO DECRYPT THE STRING, just get it back to original encrypted value)? thanks

mike.tihonchik
  • 6,855
  • 3
  • 32
  • 47

1 Answers1

2

So to summarize, the problem you are facing is that you want to transmit binary data over HTTP. (This has nothing to do with encryption; that just complicates the issue.) The funny thing is, we transmit binary data over HTTP all the time! (Images, etc.)

You need to clarify how exactly you are planning on transmitting the data. Are you including it in an HTTP POST? If so, then you need to encode the data. Base64 would be ideal here.

Otherwise, you can probably transmit it in binary, it's just a matter of explaining how you need to transmit it, so the proper things (eg. Mime type?) can be setup so the data is not corrupted in the transmission.

Jonathon Reinhart
  • 132,704
  • 33
  • 254
  • 328
  • I think you misread my question. I can get a HEX string from i740 just fine (through the web-service call). My question is is there a way to convert that HEX string back to AES encrypted string? I don't think I can get AES encrypted string from i740 because it uses EBCDIC as encoding. – mike.tihonchik Nov 13 '12 at 16:11
  • EBCDID shouldn't matter. You get hex text like "F51A75..." from a web service call right? And your web client software is Java, right? If that's the case, you've WAY over-complicated your question. Instead, just ask how to convert from a hex string to a byte array in Java. If you ask that, you'll find [this answer](http://stackoverflow.com/questions/140131/convert-a-string-representation-of-a-hex-dump-to-a-byte-array-using-java). – Jonathon Reinhart Nov 13 '12 at 21:58
  • Thank you for answers. well, i tried not to over complicate the question, so I did not put the reason I needed that HEX value decoded to EBCDIC. I have to have that value, because my Java application has to write that value into DB2 table =) – mike.tihonchik Nov 13 '12 at 22:49
  • 1
    Well then that is another problem/question, probably. See [Convert String from ASCII to EBCDIC in Java?](http://stackoverflow.com/questions/368603/convert-string-from-ascii-to-ebcdic-in-java) – Jonathon Reinhart Nov 14 '12 at 01:42