2011-07-18 52 views
0

我試圖用php curl來抓取網上銀行交易。不幸的是,該銀行使用b64_md5算法將用戶名和密碼傳遞給由該腳本md5.js完成的服務器。我GOOGLE了一個PHP函數來模擬這個。但我可以找到一些幫助。b64_md5 algorithm by Paul Johnston at http://pajhome.org.uk/crypt/md5

這裏是他們的代碼來生成密碼

function checkScript(){ 
    pCheckScript.innerHTML = ""; 
    document.form_000001.pSubmit.disabled = false; 
    document.form_000001.pCancel.disabled = false; 
    document.form_000001.challenge.value = "[[email protected]" 
    document.form_000001.login_name.focus();} 
function submitForm(){ 
    var vPassword = ""; 
    for (var i = 0; i < document.form_000001.password.value.length; i++)vPassword = vPassword + "*"; 
    document.form_000001.login_name.size = 1; 
    document.form_000001.password.size = 1; 
    document.form_000001.login_name.style.visibility = "hidden"; 
    document.form_000001.password.style.visibility = "hidden"; 
    textLoginName.innerHTML = document.form_000001.login_name.value; 
    textLoginPassword.innerHTML = vPassword; 
    document.form_000001.login_name.value = b64_md5(document.form_000001.login_name.value.toLowerCase()); 
    document.form_000001.password.value = b64_md5(b64_md5(document.form_000001.password.value) + document.form_000001.challenge.value); 
    return true;} 

的queston是,怎樣把PHP函數來模擬這一點。

+0

34個問題,只有6個上傳投。看起來很低。 –

+2

這聽起來像'b64_md5'函數返回一個基地64編碼MD5散列。你不能只使用'base64_encode(md5('string'));'?請務必注意,密碼會這樣做2次,第二次添加「挑戰」。 –

回答

2

下面是使用base64_encodemd5的示例。

<?php 

// This assumes that the challenge never changes. 
$challenge = '[[email protected]'; 

$username = base64_encode(md5(strtolower('username'))); 
$password = base64_encode(md5(base64_encode(md5('password')) . $challenge));