forked from appwrite/appwrite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenSSL.php
More file actions
62 lines (56 loc) 路 1.4 KB
/
Copy pathOpenSSL.php
File metadata and controls
62 lines (56 loc) 路 1.4 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace OpenSSL;
class OpenSSL
{
const CIPHER_AES_128_GCM = 'aes-128-gcm';
/**
* @param $data
* @param $method
* @param $key
* @param int $options
* @param string $iv
* @param null $tag
* @param string $aad
* @param int $tag_length
*
* @return string
*/
public static function encrypt($data, $method, $key, $options = 0, $iv = '', &$tag = null, $aad = '', $tag_length = 16)
{
return openssl_encrypt($data, $method, $key, $options, $iv, $tag, $aad, $tag_length);
}
/**
* @param $data
* @param $method
* @param $password
* @param int $options
* @param string $iv
* @param string $tag
* @param string $aad
*
* @return string
*/
public static function decrypt($data, $method, $password, $options = 1, $iv = '', $tag = '', $aad = '')
{
return openssl_decrypt($data, $method, $password, $options, $iv, $tag, $aad);
}
/**
* @param string $method
*
* @return int
*/
public static function cipherIVLength($method)
{
return openssl_cipher_iv_length($method);
}
/**
* @param $length
* @param null $crypto_strong
*
* @return int
*/
public static function randomPseudoBytes($length, &$crypto_strong = null)
{
return openssl_random_pseudo_bytes($length, $crypto_strong);
}
}