WS-Security php中PasswordDigest的工作算法 [英] Working algorithm for PasswordDigest in WS-Security php

查看:443
本文介绍了WS-Security php中PasswordDigest的工作算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从我的航空公司供应商给出的公式创建哈希密码。我在这个网站上搜索,我从C下面的链接获得了解决方案,但是我想在PHP中。
WS-Security中PasswordDigest的工作算法



我已经尝试过这样的php,但我得到的密码摘要是错误的

  function getTimestamp()
{
$ microtime = floatval(substr((string)microtime(),1,8));
$ rounded = round($ microtime,3);
return gmdate(Y-m-d\TH:i:s)。 substr((string)$ rounded,1,strlen($ rounded))。Z;
}
$ nounce = base64_encode(mt_rand(10000000,99999999));
$ timestamp = getTimestamp();
$ password =AMADEUS; //清除密码
$ final_hashed_pa​​ssword = base64_encode(sha1($ nounce。$ timestamp.sha1($ password)));

我的价值观如此生成

 随机数:ODczNzczNzE = 
时间戳:2014-09-21T06:36:31.328Z
密码:TEST
密码摘要我得到:NjQxOThmZjViNmIwOGM0NGNiNDE1YTExNWQ3MDc2OGNlYjBjZDY2MA ==

但密码摘要应该生成如下

 正确的密码摘要:zGXsP85SuUngY7FjtnQizeO6yUk = 

我知道算法创建摘要是:

  Password_Digest = Base64(SHA-1(nonce + created + SHA-1(password)))

请帮助我在php中生成正确的哈希密码,还可以看到上面提到的解决方案的链接c#

解决方案

获得解决方案!我们必须解码随机数,然后在其上应用公式,在xml中必须发送编码的随机数


I have been creating hash password from the formula given by my airline supplier. I have search on this site and I got the solution from below link in C# but I want in PHP. Working algorithm for PasswordDigest in WS-Security

I have tried like this in php but password digest which I am getting is wrong

function getTimestamp()
{
$microtime = floatval(substr((string)microtime(), 1, 8));
$rounded = round($microtime, 3);
return gmdate("Y-m-d\TH:i:s") . substr((string)$rounded, 1, strlen($rounded))."Z";
}
$nounce = base64_encode(mt_rand(10000000, 99999999)); 
$timestamp = getTimestamp(); 
$password = "AMADEUS"; //clear password
$final_hashed_password = base64_encode(sha1($nounce.$timestamp.sha1($password)));      

My values are generating like this

Nonce: ODczNzczNzE=
Timestamp: 2014-09-21T06:36:31.328Z
password: "TEST"
password digest I got: NjQxOThmZjViNmIwOGM0NGNiNDE1YTExNWQ3MDc2OGNlYjBjZDY2MA==

but password digest should generate like this

Right password digest: zGXsP85SuUngY7FjtnQizeO6yUk=

I know the algorithm for creating the Digest is:

Password_Digest = Base64 ( SHA-1 ( nonce + created + SHA-1 ( password ) ) )

Please help me to generate right hash password in php and also please see the above link which has the solution in c#

解决方案

Got the solution!...we have to decode the nonce and then apply the formula on it and in xml we have to send the encoded nonce

这篇关于WS-Security php中PasswordDigest的工作算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆