-
Notifications
You must be signed in to change notification settings - Fork 3
/
home.php
31 lines (21 loc) · 862 Bytes
/
home.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
$var = $_GET['id'];
echo "Encrypted Text : ".$var."<br><br><br>";
function encrypt_decrypt($action, $string) {
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = 'sadgjakgdkjafkj';
$secret_iv = 'This is my secret iv';
$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;
}
$decrypted_txt = encrypt_decrypt('decrypt', $var);
echo "Decrypted Text =" .$decrypted_txt. "\n";
?>