Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
secretfield.php
1
<?php
9
namespace
Bitrix\Main\ORM\Fields
;
10
11
use
Bitrix\Main\Security
;
12
13
class
SecretField
extends
CryptoField
14
{
15
protected
$secretLength
= 20;
16
22
public
function
__construct
(
$name
, $parameters = [])
23
{
24
//the order of modifiers is important
25
$this->
addSaveDataModifier
([$this,
'encode'
]);
26
27
parent::__construct(
$name
, $parameters);
28
29
$this->
addFetchDataModifier
([$this,
'decode'
]);
30
31
if
(isset($parameters[
'secret_length'
]))
32
{
33
$this->
configureSecretLength
($parameters[
'secret_length'
]);
34
}
35
36
$this->
configureDefaultValue
([$this,
'getRandomBytes'
]);
37
}
38
42
public
function
configureSecretLength
($length)
43
{
44
if
($length > 0)
45
{
46
$this->secretLength = (int)$length;
47
}
48
}
49
55
public
function
encode
($data)
56
{
57
return
base64_encode($data);
58
}
59
65
public
function
decode
($data)
66
{
67
return
base64_decode($data);
68
}
69
73
public
function
getRandomBytes
()
74
{
75
return
Security\Random::getBytes($this->secretLength);
76
}
77
}
Bitrix\Main\ORM\Fields\CryptoField
Definition
cryptofield.php:14
Bitrix\Main\ORM\Fields\Field\$name
$name
Definition
field.php:27
Bitrix\Main\ORM\Fields\Field\addFetchDataModifier
addFetchDataModifier($modifier)
Definition
field.php:344
Bitrix\Main\ORM\Fields\Field\addSaveDataModifier
addSaveDataModifier($modifier)
Definition
field.php:420
Bitrix\Main\ORM\Fields\ScalarField\configureDefaultValue
configureDefaultValue($value)
Definition
scalarfield.php:202
Bitrix\Main\ORM\Fields\SecretField
Definition
secretfield.php:14
Bitrix\Main\ORM\Fields\SecretField\configureSecretLength
configureSecretLength($length)
Definition
secretfield.php:42
Bitrix\Main\ORM\Fields\SecretField\decode
decode($data)
Definition
secretfield.php:65
Bitrix\Main\ORM\Fields\SecretField\getRandomBytes
getRandomBytes()
Definition
secretfield.php:73
Bitrix\Main\ORM\Fields\SecretField\encode
encode($data)
Definition
secretfield.php:55
Bitrix\Main\ORM\Fields\SecretField\__construct
__construct($name, $parameters=[])
Definition
secretfield.php:22
Bitrix\Main\ORM\Fields\SecretField\$secretLength
$secretLength
Definition
secretfield.php:15
Bitrix\Main\ORM\Fields
Definition
arrayfield.php:9
Bitrix\Main\Security
Definition
asymmetriccipher.php:8
modules
main
lib
orm
fields
secretfield.php
Создано системой
1.10.0