1C-Bitrix
25.700.0
Toggle main menu visibility
Титульная страница
Пространства имен
Пространства имен
Члены пространств имен
Указатель
$
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Функции
_
a
c
d
e
f
g
h
i
k
l
m
o
p
r
s
t
u
v
w
Переменные
$
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
v
w
Перечисления
a
b
c
d
e
f
g
l
m
n
o
p
r
s
t
u
v
w
Элементы перечислений
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
w
Структуры данных
Структуры данных
Алфавитный указатель структур данных
Иерархия классов
Поля структур
Указатель
$
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Функции
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Переменные
$
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Перечисления
Элементы перечислений
Файлы
Файлы
Список членов всех файлов
Указатель
$
(
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
б
в
к
л
о
п
с
т
ю
Функции
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Переменные
$
(
_
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
y
б
в
к
л
о
п
с
т
ю
Блог
Хостинг
1C-Bitrix
Пространства имен
Структуры данных
Файлы
Файлы
bitrix
modules
abtest
advertising
b24connector
bitrixcloud
bizproc
bizprocdesigner
blog
calendar
catalog
clouds
cluster
conversion
currency
eshopapp
fileman
form
forum
highloadblock
iblock
idea
im
landing
ldap
learning
lists
location
mail
main
classes
cli
include
interface
lib
access
analytics
authentication
cli
Command
component
composite
config
context
controller
copy
data
db
di
diag
discount
engine
Entity
eventlog
File
FileUploader
filter
grid
html
io
License
localization
mail
Messenger
numerator
orm
annotations
data
fields
relations
validators
arrayfield.php
booleanfield.php
cryptofield.php
datefield.php
datetimefield.php
decimalfield.php
enumfield.php
expressionfield.php
field.php
fielderror.php
fieldtypemask.php
floatfield.php
integerfield.php
ireadable.php
istorable.php
itypehintable.php
objectfield.php
scalarfield.php
secretfield.php
stringfield.php
textfield.php
usertypefield.php
usertypeutsmultiplefield.php
objectify
query
entity.php
entityerror.php
event.php
eventmanager.php
eventresult.php
loader.php
page
phonenumber
Provider
rating
Repository
rest
routing
search
security
service
session
SidePanel
sms
test
text
type
ui
update
UpdateSystem
urlpreview
userconsent
userfield
Validation
web
AccessDeniedException.php
application.php
ArgumentException.php
ArgumentNullException.php
ArgumentOutOfRangeException.php
ArgumentTypeException.php
ClassLocator.php
context.php
DecodingException.php
environment.php
error.php
errorable.php
errorableimplementation.php
errorcollection.php
event.php
eventmanager.php
eventresult.php
file.php
finderdest.php
group.php
grouptask.php
httpapplication.php
httpcontext.php
httprequest.php
httpresponse.php
InvalidOperationException.php
license.php
loader.php
modulemanager.php
moduletable.php
NotImplementedException.php
NotSupportedException.php
ObjectException.php
ObjectNotFoundException.php
ObjectPropertyException.php
operation.php
request.php
response.php
result.php
senderconnector.php
server.php
site.php
sitedomain.php
sitetemplate.php
SystemException.php
task.php
taskoperation.php
urlrewriter.php
UrlRewriterRuleMaker.php
user.php
useraccess.php
userauthaction.php
usercounter.php
userfield.php
userfieldconfirm.php
userfieldlangtable.php
usergroup.php
userindex.php
userphoneauth.php
userprofilehistory.php
userprofilerecord.php
userutils.php
UuidGenerator.php
xmlwriter.php
meta
public
services
tools
.settings.php
admin_tools.php
ajax_tools.php
bx_root.php
checklist_structure.php
countries.php
default_option.php
filter_tools.php
img.php
include.php
jscore.php
option_triggers.php
options.php
prolog.php
spread.php
start.php
tools.php
messageservice
mobileapp
perfmon
photogallery
pull
report
rest
sale
scale
search
security
sender
seo
socialnetwork
socialservices
statistic
storeassist
subscribe
support
translate
ui
vote
webservice
wiki
workflow
Список членов всех файлов
Примеры
•
Указатель
Структуры данных
Пространства имен
Файлы
Функции
Переменные
Перечисления
Элементы перечислений
Страницы
Загрузка...
Поиск...
Не найдено
cryptofield.php
См. документацию.
1
<?php
8
9
namespace
Bitrix\Main\ORM\Fields;
10
11
use Bitrix\Main\Security;
12
13
class
CryptoField
extends
TextField
14
{
15
protected
$cryptoKey
;
16
17
// we might want to use different algorithms, so single var might not be enough
19
protected
static
$cipher
;
20
31
public
function
__construct
(
$name
, $parameters =
array
())
32
{
33
parent::__construct(
$name
, $parameters);
34
35
$enabled =
true
;
36
if
(isset($parameters[
'crypto_enabled'
]))
37
{
38
$enabled = (bool)$parameters[
'crypto_enabled'
];
39
}
40
41
if
($enabled)
42
{
43
if
(isset($parameters[
'crypto_key'
]) && $parameters[
'crypto_key'
] <>
''
)
44
{
45
$this->cryptoKey = $parameters[
'crypto_key'
];
46
}
47
else
48
{
49
// get the key from the settings
50
if
((
$key
= static::getDefaultKey()) <>
''
)
51
{
52
$this->cryptoKey =
$key
;
53
}
54
}
55
56
if
(static::cryptoAvailable($this->cryptoKey))
57
{
58
$this->
addSaveDataModifier
(
array
($this,
'encrypt'
));
59
$this->
addFetchDataModifier
(
array
($this,
'decrypt'
));
60
}
61
else
62
{
63
throw
new \Bitrix\Main\NotSupportedException(
"Crypto is not available."
);
64
}
65
}
66
}
31
public
function
__construct
(
$name
, $parameters =
array
()) {
…
}
67
73
public
static
function
cryptoAvailable
(
$key
=
''
)
74
{
75
if
(
$key
==
''
)
76
{
77
// get the key from the settings
78
$key
= static::getDefaultKey();
79
}
80
81
if
(
$key <>
''
)
82
{
83
if
(static::$cipher ===
null
)
84
{
85
try
86
{
87
static::$cipher =
new
Security\Cipher
();
88
}
89
catch
(
Security
\
SecurityException
$e)
90
{
91
static::$cipher =
false
;
92
}
93
}
94
}
95
96
return
(
$key <>
''
&& static::$cipher);
97
}
73
public
static
function
cryptoAvailable
(
$key
=
''
) {
…
}
98
99
public
static
function
getDefaultKey
()
100
{
101
// get the key from the settings
102
$options
=
\Bitrix\Main\Config\Configuration::getValue
(
"crypto"
);
103
if
(isset(
$options
[
"crypto_key"
]))
104
{
105
return
$options
[
"crypto_key"
];
106
}
107
return
''
;
108
}
99
public
static
function
getDefaultKey
() {
…
}
109
110
public
function
encrypt
(
$data
)
111
{
112
if
(
$data
==
''
)
113
{
114
//is empty data still a secret?
115
return
$data
;
116
}
117
try
118
{
119
//encrypt the data
120
$value = static::$cipher->encrypt(
$data
, $this->cryptoKey);
121
return
base64_encode($value);
122
}
123
catch
(
Security
\
SecurityException
$e)
124
{
125
trigger_error(
"Error on encrypting the field {$this->getEntity()->getName()}.{$this->getName()}: {$e->getMessage()}"
, E_USER_WARNING);
126
return
null
;
127
}
128
}
110
public
function
encrypt
(
$data
) {
…
}
129
130
public
function
decrypt
(
$data
)
131
{
132
if
(
$data
==
''
)
133
{
134
//is empty data still a secret?
135
return
$data
;
136
}
137
try
138
{
139
//decrypt the data
140
$value = base64_decode(
$data
);
141
$value = static::$cipher->decrypt($value, $this->cryptoKey);
142
return
$value;
143
}
144
catch
(
Security
\
SecurityException
$e)
145
{
146
trigger_error(
"Error on decrypting the field {$this->getEntity()->getName()}.{$this->getName()}: {$e->getMessage()}"
, E_USER_WARNING);
147
return
null
;
148
}
149
}
130
public
function
decrypt
(
$data
) {
…
}
150
}
13
class
CryptoField
extends
TextField
{
…
};
Bitrix\Main\Config\Configuration\getValue
static getValue($name)
Определения
configuration.php:24
Bitrix\Main\ORM\Fields\CryptoField
Определения
cryptofield.php:14
Bitrix\Main\ORM\Fields\CryptoField\encrypt
encrypt($data)
Определения
cryptofield.php:110
Bitrix\Main\ORM\Fields\CryptoField\cryptoAvailable
static cryptoAvailable($key='')
Определения
cryptofield.php:73
Bitrix\Main\ORM\Fields\CryptoField\getDefaultKey
static getDefaultKey()
Определения
cryptofield.php:99
Bitrix\Main\ORM\Fields\CryptoField\decrypt
decrypt($data)
Определения
cryptofield.php:130
Bitrix\Main\ORM\Fields\CryptoField\__construct
__construct($name, $parameters=array())
Определения
cryptofield.php:31
Bitrix\Main\ORM\Fields\CryptoField\$cipher
static $cipher
Определения
cryptofield.php:19
Bitrix\Main\ORM\Fields\CryptoField\$cryptoKey
$cryptoKey
Определения
cryptofield.php:15
Bitrix\Main\ORM\Fields\Field\$name
$name
Определения
field.php:27
Bitrix\Main\ORM\Fields\Field\addFetchDataModifier
addFetchDataModifier($modifier)
Определения
field.php:351
Bitrix\Main\ORM\Fields\Field\addSaveDataModifier
addSaveDataModifier($modifier)
Определения
field.php:427
Bitrix\Main\ORM\Fields\TextField
Определения
textfield.php:20
Bitrix\Main\Security\Cipher
Определения
cipher.php:11
Bitrix\Main\Security\SecurityException
Определения
securityexception.php:6
$options
$options
Определения
commerceml2.php:49
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Main\Security
Определения
asymmetriccipher.php:8
$key
if(empty($signedUserToken)) $key
Определения
quickway.php:257
bitrix
modules
main
lib
orm
fields
cryptofield.php
Создано системой
1.14.0