Rev 846 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 846 | Rev 874 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | /** |
3 | /** |
4 | * Common String Functions |
4 | * Common String Functions |
5 | * |
5 | * |
6 | * PHP version 5 |
6 | * PHP version 5 |
7 | * |
7 | * |
- | 8 | * @category Common |
|
- | 9 | * @package Functions\Strings |
|
8 | * @author Jim Wigginton <terrafrost@php.net> |
10 | * @author Jim Wigginton <terrafrost@php.net> |
9 | * @copyright 2016 Jim Wigginton |
11 | * @copyright 2016 Jim Wigginton |
10 | * @license http://www.opensource.org/licenses/mit-license.html MIT License |
12 | * @license http://www.opensource.org/licenses/mit-license.html MIT License |
11 | * @link http://phpseclib.sourceforge.net |
13 | * @link http://phpseclib.sourceforge.net |
12 | */ |
14 | */ |
Line 17... | Line 19... | ||
17 | use phpseclib3\Math\Common\FiniteField; |
19 | use phpseclib3\Math\Common\FiniteField; |
18 | 20 | ||
19 | /** |
21 | /** |
20 | * Common String Functions |
22 | * Common String Functions |
21 | * |
23 | * |
- | 24 | * @package Functions\Strings |
|
22 | * @author Jim Wigginton <terrafrost@php.net> |
25 | * @author Jim Wigginton <terrafrost@php.net> |
23 | */ |
26 | */ |
24 | abstract class Strings |
27 | abstract class Strings |
25 | { |
28 | { |
26 | /** |
29 | /** |
Line 28... | Line 31... | ||
28 | * |
31 | * |
29 | * Inspired by array_shift |
32 | * Inspired by array_shift |
30 | * |
33 | * |
31 | * @param string $string |
34 | * @param string $string |
32 | * @param int $index |
35 | * @param int $index |
- | 36 | * @access public |
|
33 | * @return string |
37 | * @return string |
34 | */ |
38 | */ |
35 | public static function shift(&$string, $index = 1) |
39 | public static function shift(&$string, $index = 1) |
36 | { |
40 | { |
37 | $substr = substr($string, 0, $index); |
41 | $substr = substr($string, 0, $index); |
Line 44... | Line 48... | ||
44 | * |
48 | * |
45 | * Inspired by array_pop |
49 | * Inspired by array_pop |
46 | * |
50 | * |
47 | * @param string $string |
51 | * @param string $string |
48 | * @param int $index |
52 | * @param int $index |
- | 53 | * @access public |
|
49 | * @return string |
54 | * @return string |
50 | */ |
55 | */ |
51 | public static function pop(&$string, $index = 1) |
56 | public static function pop(&$string, $index = 1) |
52 | { |
57 | { |
53 | $substr = substr($string, -$index); |
58 | $substr = substr($string, -$index); |
Line 153... | Line 158... | ||
153 | /** |
158 | /** |
154 | * Create SSH2-style string |
159 | * Create SSH2-style string |
155 | * |
160 | * |
156 | * @param string $format |
161 | * @param string $format |
157 | * @param string|int|float|array|bool ...$elements |
162 | * @param string|int|float|array|bool ...$elements |
- | 163 | * @access public |
|
158 | * @return string |
164 | * @return string |
159 | */ |
165 | */ |
160 | public static function packSSH2($format, ...$elements) |
166 | public static function packSSH2($format, ...$elements) |
161 | { |
167 | { |
162 | $format = self::formatPack($format); |
168 | $format = self::formatPack($format); |
Line 225... | Line 231... | ||
225 | /** |
231 | /** |
226 | * Expand a pack string |
232 | * Expand a pack string |
227 | * |
233 | * |
228 | * Converts C5 to CCCCC, for example. |
234 | * Converts C5 to CCCCC, for example. |
229 | * |
235 | * |
- | 236 | * @access private |
|
230 | * @param string $format |
237 | * @param string $format |
231 | * @return string |
238 | * @return string |
232 | */ |
239 | */ |
233 | private static function formatPack($format) |
240 | private static function formatPack($format) |
234 | { |
241 | { |
Line 248... | Line 255... | ||
248 | * bin2hex / hex2bin refer to base-256 encoded data as binary, whilst |
255 | * bin2hex / hex2bin refer to base-256 encoded data as binary, whilst |
249 | * decbin / bindec refer to base-2 encoded data as binary. For the purposes |
256 | * decbin / bindec refer to base-2 encoded data as binary. For the purposes |
250 | * of this function, bin refers to base-256 encoded data whilst bits refers |
257 | * of this function, bin refers to base-256 encoded data whilst bits refers |
251 | * to base-2 encoded data |
258 | * to base-2 encoded data |
252 | * |
259 | * |
- | 260 | * @access public |
|
253 | * @param string $x |
261 | * @param string $x |
254 | * @return string |
262 | * @return string |
255 | */ |
263 | */ |
256 | public static function bits2bin($x) |
264 | public static function bits2bin($x) |
257 | { |
265 | { |
Line 294... | Line 302... | ||
294 | } |
302 | } |
295 | 303 | ||
296 | /** |
304 | /** |
297 | * Convert bits to binary data |
305 | * Convert bits to binary data |
298 | * |
306 | * |
- | 307 | * @access public |
|
299 | * @param string $x |
308 | * @param string $x |
300 | * @return string |
309 | * @return string |
301 | */ |
310 | */ |
302 | public static function bin2bits($x, $trim = true) |
311 | public static function bin2bits($x, $trim = true) |
303 | { |
312 | { |
Line 332... | Line 341... | ||
332 | } |
341 | } |
333 | 342 | ||
334 | /** |
343 | /** |
335 | * Switch Endianness Bit Order |
344 | * Switch Endianness Bit Order |
336 | * |
345 | * |
- | 346 | * @access public |
|
337 | * @param string $x |
347 | * @param string $x |
338 | * @return string |
348 | * @return string |
339 | */ |
349 | */ |
340 | public static function switchEndianness($x) |
350 | public static function switchEndianness($x) |
341 | { |
351 | { |
Line 362... | Line 372... | ||
362 | /** |
372 | /** |
363 | * Increment the current string |
373 | * Increment the current string |
364 | * |
374 | * |
365 | * @param string $var |
375 | * @param string $var |
366 | * @return string |
376 | * @return string |
- | 377 | * @access public |
|
367 | */ |
378 | */ |
368 | public static function increment_str(&$var) |
379 | public static function increment_str(&$var) |
369 | { |
380 | { |
370 | if (function_exists('sodium_increment')) { |
381 | if (function_exists('sodium_increment')) { |
371 | $var = strrev($var); |
382 | $var = strrev($var); |