Good Day to all!
I am trying desperately to solve the following problem and need the help
of a Rails/Ruby guru. I am receiving data via a POST request from a
remote web application. The information is composed of 5 fields of data
plus a sixth field that’s the encoded version of the first 5 bits plus
a shared secret. The problem I am having is converting the sample code I
was given (Java) to Ruby so that I can re-hash the data in my Rails app
to confirm the validity of the data.
The allDataElements string is the same for both sets of code - a string
of key, value pairs from the POST plus the shared secret
Once I hash this text I should be able to compare it to the hashed value
I was passed in the POST request.
Here’s the Java code:
//Generate hash from profile data in hashmap object
MessageDigest md = MessageDigest.getInstance(“MD5”);
byte mashedHash = md.digest(allDataElements.getBytes(“UTF-8”));
BASE64Encoder encoder = new BASE64Encoder();
//Encode to pass as a printable String to The Hartford website
yourhashedKey = encoder.encode(mashedHash);
Here’s my ruby code:
yourhashedKey = =
The return value from my code does not match what I receive from the
Java code. I believe it has to do with teh UTF-8 parameter in the
getBytes function. Can someone help? I’m desperate!!!
Thank you for your help.