Tuesday 7 May 2013

Decode MD5 in php, magento


?php
function decode_md5($hash)
{
  //simple check for md5 hash
  if(!preg_match('/^[a-f0-9]{32}$/i',$hash))return '';

  //make request to service
  $pass=file_get_contents('http://md5.darkbyte.ru/api.php?q='.$hash);

  //not found
  if(!$pass)return '';

  //found, but not valid
  if(md5($pass)!=strtolower($hash))return '';

  //found :)
  return $pass;
}

function encode_md5($pass)
{
  //add padding, if str length eq 32
  if(strlen($pass)==32)$pass.='=';
 
  //make request to service
  return file_get_contents('http://md5.darkbyte.ru/api.php?q='.urlencode($pass));
}
?>

<?php
echo $pass=decode_md5('b70d2c477ff9129a937efc41f2424ae0'); ?>

No comments:

Post a Comment