| Server IP : 172.67.187.206 / Your IP : 172.71.28.156 Web Server : Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30 System : Windows NT WIN-ECQAAA40806 6.2 build 9200 (Windows Server 2012 Standard Edition) i586 User : SYSTEM ( 0) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : E:/Inetpub/www/news/csr/include/ |
Upload File : |
<?php
// SHA-256
function stringEncryption($action, $string){
$output = false;
$encrypt_method = 'AES-256-CBC';
$secret_key = '@comhacker_key#$'; // ตั้งค่า key 16, 24, or 32 byte
$secret_iv = '!@_$2'; // เปลี่ยนตามใจชอบเอาไว้ถอดรหัส
$key = hash('sha256', $secret_key);
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if( $action == 'encrypt' ) {
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
}
else if( $action == 'decrypt' ){
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}
/* ตัวอย่างการใช้งาน */
//$text = '123456<br>';
//echo "ข้อความปกติ $text <br>";
//$encrypted = stringEncryption('encrypt', $text);
//echo "หลังเข้ารหัส : $encrypted <br>";
//$decrypted = stringEncryption('decrypt', $encrypted);
//echo "หลังถอดรหัส : $decrypted <br>";
?>