-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_ENCRYPTION.php
36 lines (30 loc) · 1.09 KB
/
_ENCRYPTION.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
<?php
class ENCREYPTION{
/**
* Encode - Encrypt string
*
* @param string $data - String to encode
* @param string $key - Secret Hex_key(optional)
* @param string $enc_method - 16 length encryption method algoridom(optional)
*
* @return string Encrypted string
*/
static function ENCODE(string $data, string $key = '7365637265745f6b6579', string $enc_method = 'AES-256-ctr'){
$md5_key=md5($key,true);
return base64_encode(openssl_encrypt($data, $enc_method, $key, 0, $md5_key));
}
/**
* Decode - Decrypt encrypted string
*
* @param string $data - String to encode
* @param string $key - Secret Hex_key(optional)
* @param string $enc_method - 16 length encryption method algoridom(optional)
*
* @return string Decoded string
*/
static function DECODE(string $data, string $key = '7365637265745f6b6579', string $enc_method = 'AES-256-ctr'){
$md5_key=md5($key,true);
return openssl_decrypt(base64_decode($data), $enc_method, $key, 0, $md5_key);
}
}
?>