Add missing PHP doc to hash and string generating functions

[MAILPOET-1900]
This commit is contained in:
Rostislav Wolny
2019-08-21 16:55:07 +02:00
committed by Pavel Dohnal
parent 0aa1d65822
commit 82123afc7c

View File

@@ -15,6 +15,8 @@ class Security {
* Generate random lowercase alphanumeric string. * Generate random lowercase alphanumeric string.
* 1 lowercase alphanumeric character = 6 bits (because log2(36) = 5.17) * 1 lowercase alphanumeric character = 6 bits (because log2(36) = 5.17)
* So 3 bytes = 4 characters * So 3 bytes = 4 characters
* @param int $length Minimal lenght is 5
* @return string
*/ */
static function generateRandomString($length = 5) { static function generateRandomString($length = 5) {
$length = max(5, (int)$length); $length = max(5, (int)$length);
@@ -22,7 +24,11 @@ class Security {
return substr($string, 0, $length); return substr($string, 0, $length);
} }
static function generateHash($length = false) { /**
* @param int $length Maximal length is 32
* @return string
*/
static function generateHash($length = null) {
$length = ($length) ? $length : self::HASH_LENGTH; $length = ($length) ? $length : self::HASH_LENGTH;
$auth_key = ''; $auth_key = '';
if (defined('AUTH_KEY')) { if (defined('AUTH_KEY')) {