@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * (64 characters for example) for keeping high entropy. |
| 86 | 86 | * The pass-phrase is converted internaly into |
| 87 | 87 | * a binary key that is to be used for encryption. |
| 88 | - * @return mixed base64 encrypted string, FALSE on failure. |
|
| 88 | + * @return string|false base64 encrypted string, FALSE on failure. |
|
| 89 | 89 | */ |
| 90 | 90 | public static function enc($string, $pass) { |
| 91 | 91 | |
@@ -283,6 +283,10 @@ discard block |
||
| 283 | 283 | return self::mbstring_func_overload() ? mb_strlen($str, '8bit') : strlen($str); |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | + /** |
|
| 287 | + * @param integer $start |
|
| 288 | + * @param integer $length |
|
| 289 | + */ |
|
| 286 | 290 | protected static function substr($str, $start, $length = null) { |
| 287 | 291 | |
| 288 | 292 | if (self::mbstring_func_overload()) { |
@@ -296,6 +300,9 @@ discard block |
||
| 296 | 300 | return isset($length) ? substr($str, $start, $length) : substr($str, $start); |
| 297 | 301 | } |
| 298 | 302 | |
| 303 | + /** |
|
| 304 | + * @param integer $length |
|
| 305 | + */ |
|
| 299 | 306 | protected static function random_bytes($length) { |
| 300 | 307 | |
| 301 | 308 | $length = (int) $length; |
@@ -440,6 +447,11 @@ discard block |
||
| 440 | 447 | */ |
| 441 | 448 | } |
| 442 | 449 | |
| 450 | + /** |
|
| 451 | + * @param string $string |
|
| 452 | + * @param string $key |
|
| 453 | + * @param string $iv |
|
| 454 | + */ |
|
| 443 | 455 | protected static function aes_cbc_encrypt($string, $key, $iv) { |
| 444 | 456 | |
| 445 | 457 | $key_size = self::$key_size; |
@@ -472,6 +484,11 @@ discard block |
||
| 472 | 484 | return false; |
| 473 | 485 | } |
| 474 | 486 | |
| 487 | + /** |
|
| 488 | + * @param string $crypted |
|
| 489 | + * @param string $key |
|
| 490 | + * @param string $iv |
|
| 491 | + */ |
|
| 475 | 492 | protected static function aes_cbc_decrypt($crypted, $key, $iv) { |
| 476 | 493 | |
| 477 | 494 | $key_size = self::$key_size; |
@@ -512,6 +529,9 @@ discard block |
||
| 512 | 529 | return $string.str_repeat(chr($pad), $pad); |
| 513 | 530 | } |
| 514 | 531 | |
| 532 | + /** |
|
| 533 | + * @param string $string |
|
| 534 | + */ |
|
| 515 | 535 | protected static function remove_pkcs7_pad($string) { |
| 516 | 536 | |
| 517 | 537 | // 128 bits: $block_length = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC); |
@@ -216,8 +216,7 @@ discard block |
||
| 216 | 216 | { |
| 217 | 217 | $test = random_bytes(1); |
| 218 | 218 | self::$random_bytes_exists = true; |
| 219 | - } |
|
| 220 | - catch (Exception $e) { |
|
| 219 | + } catch (Exception $e) { |
|
| 221 | 220 | // Do nothing. |
| 222 | 221 | } |
| 223 | 222 | } |
@@ -305,8 +304,7 @@ discard block |
||
| 305 | 304 | try |
| 306 | 305 | { |
| 307 | 306 | return random_bytes($length); |
| 308 | - } |
|
| 309 | - catch (Exception $e) { |
|
| 307 | + } catch (Exception $e) { |
|
| 310 | 308 | // Do nothing, continue. |
| 311 | 309 | } |
| 312 | 310 | } |