-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAES.php
More file actions
23 lines (21 loc) · 791 Bytes
/
AES.php
File metadata and controls
23 lines (21 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
function encrypt($key,$iv,$data)
{
$method = 'AES-128-CBC';
$ivsize = openssl_cipher_iv_length($method);
$en = openssl_encrypt($data,$method,$key,OPENSSL_RAW_DATA,$iv);
return base64_encode($en);
}
function decrypt($key,$iv,$data)
{
$method = 'AES-128-CBC';
$data = base64_decode($data);
$ivsize = openssl_cipher_iv_length($method);
$data = openssl_decrypt($data
,$method,$key,OPENSSL_RAW_DATA,$iv);
return $data;
}
print encrypt('0123456789012345','0123456789012345','@dorsateam');
print "\n";
print decrypt('0123456789012345','0123456789012345','MROdbaxFiWmPtj3OvjWICA==');
?>