我更改了Ruby代码片段,现在它可以工作了,我忘记在上一篇文章中添加md5部分了,抱歉。之后,我还重新测试了PHP代码片段,现在两个输出是相同的。
这是我到目前为止所知道的:
PHP:
"Inx ".base64_encode('Jon').' '.base64_encode(pack( 'H*' , md5($message."werty")))Ruby:
md5 = Digest::MD5.digest(msg +"werty")
auth = "Inx " + Base64.b64encode('Jon').strip() + " " + Base64.b64encode(md5).strip()输出为:
PHP:
Inx Sm9u FL6ZQ1EAMcVDpUhGQ9kxjg==Ruby:
Inx Sm9u FL6ZQ1EAMcVDpUhGQ9kxjg==下面是使用的消息:
<?xml version="1.0" encoding="UTF-8"?> <push><application>Jon</application><service><![CDATA[test-2]]></service><service-provider>Absolute</service-provider><session-id>jbg01</session-id><trigger>bulk link</trigger><sms-text url="http://example.com" url-tag="xxx"><![CDATA[Hello world]]></sms-text><recipient>555555</recipient><from>5555</from></push>我更改了xml中的一些敏感信息,因此它与PHP字符串中使用的字符串不完全相同。
发布于 2010-07-02 05:42:49
require "digest/md5"
Digest::MD5.digest(string)直接生成二进制MD5摘要(16字节),您不需要pack
https://stackoverflow.com/questions/3161658
复制相似问题