Dienstag, 22. November 2011

Encode and decode Dreamweaver password in PHP

If you want to generate a Dreamweaver site file (.ste) so you can import it, you need to encode the password for Dreamweaver. You can learn from Andrew Odri that the encryption is very bad. He wrote encode and decode functions for this in Javascript. Doing the same in PHP is way easier. Of course you can use this page to decode your side export. But they do not explain how it works:

function encodePassword($input)
{
  $output = '';
  
  for($i = 0; $i < strlen($input); $i++)
  {
    $output .= dechex(ord($input[$i]) + $i);
  }

  return strtoupper($output);
}


function decodePassword($input)
{
  $output = '';
  
  for($i = 0; $i < strlen($input); $i += 2)
  {
    $output .= chr(hexdec($input[$i].$input[$i+1]) - $i/2);
  }

  return ($output);
}

Like it? Share it! Flattr this

Keine Kommentare: