I'm trying to figure out if it's possible to convert the following MD5 conversion of a password and challenge from a method in my Rails application into jQuery. So far, I've failed at every hurdle.
Basically, I'm trying to take a username / password / challenge from a form and submit it to an external url.
It works in our Rails application but we need to post via ajax / jquery.
def my_method
hex_chal = Array[params['challenge']].pack('H32')
newchal = Array[Digest::MD5.hexdigest(hex_chal + secret)].pack('H*')
response = Digest::MD5.hexdigest("\0" + params['password'] + newchal)
new_pwd = Array[params['password']].pack('a32')
end
Using the jquery md5 library, I have tried something like this:
function Test() {
...
var hex_chal = $.md5(params('challenge'));
var new_chal = $.md5(hex_chal + params('password'));
...
}
No idea if this is possible. If it's not, I'll have to find another way to do it.