duplicating the md5 raw_output flag (raw bytes) in PHP 5 with Ruby's md5

NoOBAMAH

New Member
Due to an absurd SOAP authentication scheme I need to md5 hash an API key with some other parameters. Unfortunately the only sample code provided is written in PHP and, for reasons I find unfathomable, it requires that the md5 hashing use the optional raw_output flag in PHP (http://php.net/manual/en/function.md5.php) which causes it to return binary (which I then have to base64 encode).My app is written in Ruby and I don't want to defer this portion to a PHP file if I don't have to. However, I can't seem to find out how to get Ruby to return the hash in binary. When I hash it normally in PHP, the output matches my Ruby output, but that's not what they're asking for.PHP:\[code\]<?php $encode = "test"; echo md5($encode); // 098f6bcd4621d373cade4e832627b4f6 echo "\n"; // PHP5 - md5 with raw_output flag set to true - what I need to mimic in Ruby echo md5($encode, true); // binary that looks something like: ?k?F!?s??N?&'?? echo "\n";?>\[/code\]Ruby:\[code\]require 'digest/md5'encode = "test"puts Digest::MD5.hexdigest(encode) # 098f6bcd4621d373cade4e832627b4f6\[/code\]Any assistance is appreciated.
 
Back
Top