fork download
  1. <?
  2.  
  3. function padding($msg,$nb_chars)
  4. {
  5. $charset = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9');
  6. for($cpt=0;$cpt<$nb_chars;$cpt++)
  7. {
  8. $rand = rand(0,61);
  9. $msg .= $charset[$rand];
  10. }
  11. return $msg;
  12. }
  13.  
  14. function mac($msg)
  15. {
  16.  
  17. $key = "7h3_1337_k3y";
  18. $nonce = "5uc3m01";
  19. $bloc_size = 64;
  20. if(strlen($msg)<$bloc_size)
  21. {
  22. $msg = padding($msg,$bloc_size-strlen($msg));
  23. $mac = $msg;
  24. }
  25. else if(strlen($msg)==$bloc_size)
  26. {
  27. $mac = $msg;
  28. }
  29. else if(strlen($msg)>$bloc_size)
  30. {
  31. $mac = hash_hmac("sha512",$msg.$nonce,$key,true);
  32. }
  33. return crypt($mac,'$6$rounds=5000$OhMyG05h!');
  34.  
  35.  
  36. }
  37.  
  38.  
  39. $test = "dededededededededededededededededededededededededededededededed";
  40. $cpt = 0;
  41. $bloc_size = 64;
  42.  
  43. while($cpt < 1)
  44. {
  45. $return1 = padding($test,$bloc_size-strlen($test));
  46. $return2 = padding($test,$bloc_size-strlen($test));
  47.  
  48. $return_cry1 = crypt($return1,'$6$rounds=5000$OhMyG05h!');
  49. $return_cry2 = crypt($return2,'$6$rounds=5000$OhMyG05h!');
  50.  
  51. if($return_cry2 == $return_cry1)
  52. {
  53. $cpt = 2;
  54. print("OK\n");
  55. print $return1;
  56. print $return2;
  57. }
  58.  
  59. print("nok\n");
  60. }
  61.  
  62. ?>
  63.  
Success #stdin #stdout 0.02s 25792KB
stdin
Standard input is empty
stdout
<?

 function padding($msg,$nb_chars)
	{
		$charset = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','0','1','2','3','4','5','6','7','8','9');
		for($cpt=0;$cpt<$nb_chars;$cpt++)
		{
			$rand = rand(0,61);
			$msg .= $charset[$rand];
		}		
		return $msg;
	}	

	function mac($msg)
	{
	
		$key = "7h3_1337_k3y";
		$nonce = "5uc3m01";
		$bloc_size = 64;
		if(strlen($msg)<$bloc_size)
		{
			$msg = padding($msg,$bloc_size-strlen($msg));
			$mac = $msg;
		}
		else if(strlen($msg)==$bloc_size)
		{
			$mac = $msg;
		}
		else if(strlen($msg)>$bloc_size)
		{
			$mac = hash_hmac("sha512",$msg.$nonce,$key,true);
		}
		return crypt($mac,'$6$rounds=5000$OhMyG05h!');
		

	}
	

	$test = "dededededededededededededededededededededededededededededededed";
	$cpt = 0;
	$bloc_size = 64;
	
	while($cpt < 1)
	{
		$return1 = padding($test,$bloc_size-strlen($test));
		$return2 = padding($test,$bloc_size-strlen($test));
		
		$return_cry1 = crypt($return1,'$6$rounds=5000$OhMyG05h!');
		$return_cry2 = crypt($return2,'$6$rounds=5000$OhMyG05h!');
		
		if($return_cry2 == $return_cry1)
			{
			$cpt = 2;
			print("OK\n");
			print $return1;
			print $return2;
			}
		
		print("nok\n");
	}
	
?>