I have the following question about this php code:
<?php
class Encrypter {
private static $Key = "dublin";
public static function encrypt ($input) {
$output = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5(Encrypter::$Key), $input, MCRYPT_MODE_CBC, md5(md5(Encrypter::$Key))));
return $output;
}
public static function decrypt ($input) {
$output = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5(Encrypter::$Key), base64_decode($input), MCRYPT_MODE_CBC, md5(md5(Encrypter::$Key))), "<?php
class Encrypter {
private static $Key = "dublin";
public static function encrypt ($input) {
$output = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5(Encrypter::$Key), $input, MCRYPT_MODE_CBC, md5(md5(Encrypter::$Key))));
return $output;
}
public static function decrypt ($input) {
$output = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5(Encrypter::$Key), base64_decode($input), MCRYPT_MODE_CBC, md5(md5(Encrypter::$Key))), "%pre%");
return $output;
}
}
$texto = "Soy un ejemplo";
// Encriptamos el texto
$texto_encriptado = Encrypter::encrypt($texto);
// Desencriptamos el texto
$texto_original = Encrypter::decrypt($texto_encriptado);
echo $texto_original;
echo $texto_encriptado;
?>
");
return $output;
}
}
$texto = "Soy un ejemplo";
// Encriptamos el texto
$texto_encriptado = Encrypter::encrypt($texto);
// Desencriptamos el texto
$texto_original = Encrypter::decrypt($texto_encriptado);
echo $texto_original;
echo $texto_encriptado;
?>
The code works well, what I want is to use the same function to encrypt in javascript and decrypt using this function in php clear using the same key I hope you understand me.