1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Encryption.php
См. документацию.
1<?php
2
4
9final class Encryption
10{
11 public static function encrypt(string $str, ?string $salt = null): string
12 {
13 $key = $salt ?? \COption::GetOptionString('main', 'pwdhashadd', 'ldap');
14 $key1 = self::binMd5($key);
15 $res = '';
16 while ($str)
17 {
18 $m = substr($str, 0, 16);
19 $str = substr($str, 16, strlen($str) - 16);
20 $res .= self::byteXor($m, $key1, 16);
21 $key1 = self::binMd5($key . $key1 . $m);
22 }
23 return base64_encode($res);
24 }
25
26 public static function decrypt(string $str, ?string $salt = null): string
27 {
28 $key = $salt ?? \COption::GetOptionString('main', 'pwdhashadd', 'ldap');
29 $key1 = self::binMd5($key);
30 $str = base64_decode($str);
31 $res = '';
32 while ($str)
33 {
34 $m = substr($str, 0, 16);
35 $str = substr($str, 16, strlen($str) - 16);
36
37 $m = self::byteXor($m, $key1, 16);
38 $res .= $m;
39 $key1 = self::binMd5($key . $key1 . $m);
40 }
41 return $res;
42 }
43
50 public static function byteXor($a, $b, $l)
51 {
52 $c = '';
53 for ($i = 0; $i < $l; $i++)
54 {
55 $c .= $a[$i] ^ $b[$i];
56 }
57 return $c;
58 }
59
64 public static function binMd5($val)
65 {
66 return pack('H*', md5($val));
67 }
68}
static byteXor($a, $b, $l)
Определения Encryption.php:50
static decrypt(string $str, ?string $salt=null)
Определения Encryption.php:26
static encrypt(string $str, ?string $salt=null)
Определения Encryption.php:11
$str
Определения commerceml2.php:63
$res
Определения filter_act.php:7
$l
Определения options.php:783
if(empty($signedUserToken)) $key
Определения quickway.php:257
$i
Определения factura.php:643
else $a
Определения template.php:137
$val
Определения options.php:1793