- substr: documentation ( source)
- chr: documentation ( source)
- hash: documentation ( source)
- intval: documentation ( source)
- implode: documentation ( source)
- ord: documentation ( source)
<form action="" method="post">
<input type="text" name="challenge">
<input type="submit" value="Generuj!">
</form>
<?php
if(!empty($_POST['challenge'])){
$challenge = $_POST['challenge'];
$temp = "";
for($x=0;$x<8;$x++){
if(ord($challenge[$x]) <= 0x47){
$temp[$x] = chr(ord($challenge[$x])<<1);
}else{
$temp[$x] = chr(ord($challenge[$x])>>1);
}
}
$md5hash = hash('md5', implode('', $temp));
for($y=0;$y<8;$y++){
$byteHash[$y] = intval(substr($md5hash, $y*2, 2), 16);
}
$pass = "";
for($z=0;$z<8;$z++){
$tmp1 = ($byteHash[$z]>>1)*0xB60B60B7;
$tmp1 = $tmp1>>(5+32);
$tmp2 = $tmp1<<3;
$tmp2 = $tmp2-($tmp1<<1);
$tmp3 = $tmp2<<4;
$tmp3 = $tmp3-$tmp2;
$tmp4 = $byteHash[$z]-$tmp3+0x21;
$tmp4 = $tmp4&0xFF;
$pass .= (($tmp4 == 0x3F) ? chr(0x3E) : chr($tmp4));
}
echo 'Pass: </br>';
echo $pass;
}
?>