Last active
October 22, 2016 08:22
-
-
Save GeHou/806ebb3703015f4fddbee6195522a3b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-Type: text/plain;charset=utf-8'); | |
$data = 'phpbest'; | |
$key = 'oScGU3fj8m/tDCyvsbEhwI91M1FcwvQqWuFpPoDHlFk='; //echo base64_encode(openssl_random_pseudo_bytes(32)); | |
$iv = 'w2wJCnctEG09danPPI7SxQ=='; //echo base64_encode(openssl_random_pseudo_bytes(16)); | |
echo '内容: '.$data."\n"; | |
$encrypted = openssl_encrypt($data, 'aes-256-cbc', base64_decode($key), OPENSSL_RAW_DATA, base64_decode($iv)); | |
echo '加密: '.base64_encode($encrypted)."\n"; | |
$encrypted = base64_decode('To3QFfvGJNm84KbKG1PLzA=='); | |
$decrypted = openssl_decrypt($encrypted, 'aes-256-cbc', base64_decode($key), OPENSSL_RAW_DATA, base64_decode($iv)); | |
echo '解密: '.$decrypted."\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment