PHP Класс Dcrypt\Str

The functions in this class were inspired by the symfony's StringUtils class.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
equal ( string $known, string $given ) : boolean Compares two strings in constant time. Strings are hashed before comparison so information is not leaked when strings are not of equal length.
hashSize ( string $algo ) : integer Determine the length of the output of a given hash algorithm in bytes.
strlen ( string $string ) : integer Returns the number of bytes in a string.
substr ( string $string, integer $start, integer $length = null ) : string Returns part of a string.

Приватные методы

Метод Описание
strcmp ( string $knownHash, string $givenHash ) : boolean Private constant-time strcmp method to use when hash_equals is unavailable.

Описание методов

equal() публичный статический Метод

Compares two strings in constant time. Strings are hashed before comparison so information is not leaked when strings are not of equal length.
public static equal ( string $known, string $given ) : boolean
$known string The string of known length to compare against
$given string The string that the user can control
Результат boolean

hashSize() публичный статический Метод

Determine the length of the output of a given hash algorithm in bytes.
public static hashSize ( string $algo ) : integer
$algo string Name of algorithm to look up
Результат integer

strlen() публичный статический Метод

Returns the number of bytes in a string.
public static strlen ( string $string ) : integer
$string string The string whose length we wish to obtain
Результат integer

substr() публичный статический Метод

Returns part of a string.
public static substr ( string $string, integer $start, integer $length = null ) : string
$string string The string whose length we wish to obtain
$start integer
$length integer
Результат string the extracted part of string; or FALSE on failure, or an empty string.