PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.9.4
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.9.4
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / phpoffice / phpspreadsheet / src / PhpSpreadsheet / Reader / Xls / RC4.php

RC4.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.9.4, at vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xls/RC4.php

62 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PhpOffice\PhpSpreadsheet\Reader\Xls;
4
5 class RC4
6 {
7 // Context
8 protected $s = [];
9
10 protected $i = 0;
11
12 protected $j = 0;
13
14 /**
15 * RC4 stream decryption/encryption constrcutor.
16 *
17 * @param string $key Encryption key/passphrase
18 */
19 public function __construct($key)
20 {
21 $len = strlen($key);
22
23 for ($this->i = 0; $this->i < 256; ++$this->i) {
24 $this->s[$this->i] = $this->i;
25 }
26
27 $this->j = 0;
28 for ($this->i = 0; $this->i < 256; ++$this->i) {
29 $this->j = ($this->j + $this->s[$this->i] + ord($key[$this->i % $len])) % 256;
30 $t = $this->s[$this->i];
31 $this->s[$this->i] = $this->s[$this->j];
32 $this->s[$this->j] = $t;
33 }
34 $this->i = $this->j = 0;
35 }
36
37 /**
38 * Symmetric decryption/encryption function.
39 *
40 * @param string $data Data to encrypt/decrypt
41 *
42 * @return string
43 */
44 public function RC4($data)
45 {
46 $len = strlen($data);
47 for ($c = 0; $c < $len; ++$c) {
48 $this->i = ($this->i + 1) % 256;
49 $this->j = ($this->j + $this->s[$this->i]) % 256;
50 $t = $this->s[$this->i];
51 $this->s[$this->i] = $this->s[$this->j];
52 $this->s[$this->j] = $t;
53
54 $t = ($this->s[$this->i] + $this->s[$this->j]) % 256;
55
56 $data[$c] = chr(ord($data[$c]) ^ $this->s[$t]);
57 }
58
59 return $data;
60 }
61 }
62