Use same PHP encrypt method as in Java
<p>I've made this PHP encrypt script. Now I was wondering how this could be done in Java. I was considering giving this up, and coding it in Javascript so it could be used in both languages. This is unfortunately not what I want. How can I do so in Java?</p>

<pre><code>&lt;?php
  $encrypted = encrypt("Hello goodbye", "Pizza");
  $decrypted = decrypt($encrypted, "Pizza");

  echo $encrypted;
  echo "&lt;br/&gt;";
  echo $decrypted;

  function encrypt($string, $key) {
    $result = '';
    for($i=0; $i&lt;strlen($string); $i++) {
      $char = substr($string, $i, 1);
      $keychar = substr($key, ($i % strlen($key))-1, 1);
      $char = chr(ord($char)+ord($keychar));
      $result.=$char;
    }

    return base64_encode($result);
  }

  function decrypt($string, $key) {
    $result = '';
    $string = base64_decode($string);

    for($i=0; $i&lt;strlen($string); $i++) {
      $char = substr($string, $i, 1);
      $keychar = substr($key, ($i % strlen($key))-1, 1);
      $char = chr(ord($char)-ord($keychar));
      $result.=$char;
    }

    return $result;
  }
?&gt;
</code></pre>

<p>I am not asking to write some code for me (but it would be great), but I would like to be helped or get a push in the right direction</p>

<p><strong>EDIT:</strong>
<strong>I do not want to post and get to the PHP file via Java</strong></p>