digitalwise
asked on
Java Encryption Called in ColdFusion
Given a new project where I am way out of my depth! We have keys for encryption that need to be decrypted and then consumed. This site is built in CF8 and the sample code they sent was in Java. I have most of it transferred over calling java within CF but this line is stumping me:
How do I use java within CF to call that?
byte[] key = Base64.decode(KEY)
How do I use java within CF to call that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Well it should work ok.. but I have heard of slight differences between some base64 algorithms. If you want to try it the pure java way, just make sure the jar containing the "Base64" class in is your CF class path. (You've probably done that already). Then create an instance of it. I don't know which library "Base64" is from .. my guess would be Apache Commons, so something like:
If that doesn't work, check the "import" statements at the top of the java examples. They'll tell you the correct path.
key = createObject("java", "org.apache.commons.codec.binary.Base64").decode(theValue);
If that doesn't work, check the "import" statements at the top of the java examples. They'll tell you the correct path.
ASKER
I get a Parameter supplied to Base64 decode is not a byte[] error with that. I just opened another question related to this in its entirety since I am stuck on another spot! Thanks for looking at it again.
I get a Parameter supplied to Base64 decode is not a byte[] error with that.
Yeah, I was just guessing that class is from apache commons :) Can't be sure without seeing the java imports.
Though now that I think about it ... CF has an older version of that lib baked in. From the error, it sounds like it doesn't include the "decode(string)" method. So IF that is the library in the java example, you couldn't use that code anyway. Not without jumping through a few hoops ie Either replacing the built in version (*might* break things) or using JavaLoader.cfc.
ASKER