-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhash.set.php
42 lines (42 loc) · 899 Bytes
/
hash.set.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
32
33
34
35
36
37
38
39
40
41
42
<?php
class hash
{
private$key;
private$iv;
private$string;
private$action;
private$output;
public function catch($string,$action,$key,$iv)
{
$this->string=$string;
$this->action=$action;
$this->key=$key;
$this->iv=$iv;
if(self::crypt())
{
$output=self::crypt();
$this->output=$output;
return$this->output;
}
else
{
return false;
}
}
private function crypt()
{
$encrypt_method='AES-256-CBC';
$key=hash('SHA3-512',$this->key);
$iv=substr(hash('SHA512',$this->iv),0,16);
if($this->action==1)
{
$output=base64_encode(openssl_encrypt($this->string,$encrypt_method,$key,OPENSSL_RAW_DATA,$iv));
}
elseif($this->action==0)
{
$output=openssl_decrypt(base64_decode($this->string),$encrypt_method,$key,OPENSSL_RAW_DATA,$iv);
}
return$output;
}
}
?>