You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
simple-yewu/frontend/web/jk4.php

59 lines
1.1 KiB

<?php
class AES
{
public static function encrypt($key, $iv, $data)
{
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128, "", MCRYPT_MODE_CBC, "");
mcrypt_generic_init($td, $key, $iv);
$encrypted = mcrypt_generic($td, $data);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return base64_encode($encrypted);
}
public static function decrypt($key, $iv, $data)
{
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128,"",MCRYPT_MODE_CBC,"");
mcrypt_generic_init($td, $key, $iv);
$decode = base64_decode($data);
$dencrypted = mdecrypt_generic($td, $decode);
mcrypt_generic_deinit($td);
mcrypt_module_close($td);
return $dencrypted;
}
}
$key = "cardream90123456";
$iv = "asdfw6789012345a";
$data = "13522624321";
$code = AES::encrypt($key,$iv,$data);
echo "AES EN:";
echo $code;
echo "<br/>";
echo "public key:";
echo $key;
echo "<br/>";
echo "private key:";
echo $iv;
echo "<br/>";
echo "AES DE mobile:";
echo AES::decrypt($key,$iv,$code);
?>