Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Encryptor.php
1<?php
2
4
6
7trait Encryptor
8{
9 protected static function encrypt(string $data, string $cryptoKey): string
10 {
11 $encryptedData = '';
12 try
13 {
14 $cipher = new Cipher();
15
16 $encryptedData = $cipher->encrypt($data, $cryptoKey);
17 $encryptedData = \base64_encode($encryptedData);
18 }
19 catch (\Bitrix\Main\Security\SecurityException $e)
20 {}
21
22 return $encryptedData;
23 }
24
25 protected static function decrypt(string $encryptedData, string $cryptoKey): string
26 {
27 $decryptedData = '';
28 try
29 {
30 $cipher = new Cipher();
31
32 $decryptedData = base64_decode($encryptedData);
33 $decryptedData = $cipher->decrypt($decryptedData, $cryptoKey);
34 }
35 catch(\Bitrix\Main\Security\SecurityException $e)
36 {}
37
38 return $decryptedData;
39 }
40}