I spent 4 hours trying to figure out what's going on in the following code. I can hardly understand it, since I haven't programmed Javascript yet.
Javascript:
function pincheck() {
var n = 123456789123,
t = md5(n + " " + $("#wert").val()),
e = $("input[name='some_hash']").val();
$.post("https://url-test.com/site?check=" + t, {some_hash: e}, function(n) {
$("#inputWert").html(n == t ? "<span style='color:green; font-weight:bold'>OK</span>"
: "<span style='color:red; font-weight:bold'>NOT OK</span>")
})
}
Corresponding HTML-form:
<form action="https://url-test.com/site" method="post" accept-charset="utf-8">
<div style="display:none">
<input type="hidden" name="some_hash" value="2cb6beab7ac4240043b20674a3dce6a5" />
</div>
<input type="text" id="wert" name="wert" placeholder="WERT" onchange="pincheck()">
<div id="inputWert">Please input</div>
<input type="submit" value="Submit" />
<h2>Please explain<br/><textarea name="explain" style="width: 650px;height: 100px;" placeholder="Explanation"></textarea><br/>
</form>
My thoughts were:
- The function pincheck() checks if n==t
- But since t is a md5 hash, it can never be equal to n, which is a digit number. Is this correct? If wert=000, will be the value of the variable "t" an MD5 of the string "123456789123 000"? I hope I explained correct.
The background of my question refers to our university IT-security task. We have to guess some number, and then enter it into the text form, whos id should be "wert" I guess.
I hope someone can help me. Thank you in advance!
ns in your code and one with number value set in the beginning is not the same as one returned in ajax callback - notefunction(n)signature.