AES加密例子(python和php版本)

  <?php

  $privateKey = "1234567890abcdef";

  $iv = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";

$data = '{"a": "123中文", sss}  ';

//加密

$encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $privateKey, $data, MCRYPT_MODE_CBC, $iv);

$edata = base64_encode($encrypted);

echo $edata;echo '<br/>';

//解密

$encryptedData = base64_decode('6PIG4DBcjsDDxY9GtHq2TXjTVE5linoc/7i8CdJNTU0=');

$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $privateKey, $encryptedData, MCRYPT_MODE_CBC, $iv);

echo(rtrim($decrypted, "\0"));

?>

你可能感兴趣的:(加密,python,count)