title: What is the equivalent of this encryption and decryption code in Scala?
body: <pre><code>$KEY = "Your KEY";
  $IV = "Your IV";
  
  function addpadding($string, $blocksize = 32)
  {
      $len = strlen($string);
      $pad = $blocksize - ($len % $blocksize);
      $string .= str_repeat(chr($pad), $pad);
      return $string;
  }
  
  function strippadding($string)
  {
      $slast = ord(substr($string, -1));
      $slastc = chr($slast);
      $pcheck = substr($string, -$slast);
      if(preg_match("/$slastc{".$slast."}/", $string)){
          $string = substr($string, 0, strlen($string)-$slast);
          return $string;
      } else {
          return false;
      }
  }
  
  function encrypt($string = "")
  {
      global $KEY,$IV;
      $key = base64_decode($KEY);
      $iv = base64_decode($IV);
      return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key,  addpadding($string), MCRYPT_MODE_CBC, $iv));
  }
  
  function decrypt($string = "")
  {
      global $KEY,$IV;
      $key = base64_decode($KEY);
      $iv = base64_decode($IV);
      $string = base64_decode($string);
      return strippadding(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $string, MCRYPT_MODE_CBC, $iv));
  }
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I'm looking for the exact implementation not just references to libraries so I posted the answer by myself. I'm coding in Scala but at first I asked for Java to increase the chance of getting an answer as quickly as possible, so the implementation is in Scala language.</p>