Completed
Push — master ( b5ea74...804f63 )
by Dmitry
02:00
created

anonymous//examples/my-credentials.php$1   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 9
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A my-credentials.php$1 ➔ decode() 0 1 1
A my-credentials.php$1 ➔ encode() 0 6 2
1
<?php
2
3
/* Экземпляр класса идентификации  */
4
5
$identity = new class implements \Promopult\Integra\IdentityInterface {
6
    public function getHash(): string { return getenv('__HASH__'); }
7
    public function getCryptKey(): string { return getenv('__CRYPT_KEY__'); }
8
    public function getPartnerPath(): string { return getenv('__PARTNER_PATH__'); }
9
    public function getApiHost(): string { return getenv('__API_HOST__'); }
10
};
11
12
/* Экземпляр класса реализующий шифрование данных */
13
14
$crypt = new class implements \Promopult\Integra\CryptInterface {
15
    public function encode(string $s, string $ck): string {
16
        $r = '';
17
        for ($i = 0; $i < strlen($s); $i++) {
18
            $r .= chr(ord(substr($s, $i, 1)) + ord(substr($ck, ($i % strlen($ck)) - 1, 1)));
19
        }
20
        return base64_encode($r);
21
    }
22
    public function decode(string $string, string $key): string { return ''; }
23
};
24