PHP Класс PHPDaemon\Utils\Crypt

Автор: Vasily Zorin ([email protected])
Наследование: use trait PHPDaemon\Traits\ClassWatchdog
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
compareStrings ( string $a, string $b ) : boolean Compare strings
hash ( string $str, string $salt = '', boolean $plain = false ) : string Generate keccak hash for string with salt
randomBytes ( integer $len, callable $cb, integer $pri, boolean $hang = false ) : integer Returns string of pseudo random bytes
randomInts ( integer $numInts, callable $cb, integer $pri, boolean $hang = false ) : integer Returns array of pseudo random integers of machine-dependent size
randomInts32 ( integer $numInts, callable $cb, integer $pri, boolean $hang = false ) : integer Returns array of pseudo random 32-bit integers
randomString ( integer $len = null, string $chars = null, callable $cb = null, integer $pri, boolean $hang = false ) : string Returns string of pseudo random characters
stringIdx ( string $str, integer $idx ) : string Returns the character at index $idx in $str in constant time

Защищенные методы

Метод Описание
getMinimalBitMask ( integer $toRepresent ) : integer Returns the smallest bit mask of all 1s such that ($toRepresent & mask) = $toRepresent

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

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

Compare strings
Устаревший:
public static compareStrings ( string $a, string $b ) : boolean
$a string String 1
$b string String 2
Результат boolean Equal?

getMinimalBitMask() защищенный статический Метод

Returns the smallest bit mask of all 1s such that ($toRepresent & mask) = $toRepresent
protected static getMinimalBitMask ( integer $toRepresent ) : integer
$toRepresent integer must be an integer greater than or equal to 1
Результат integer

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

Generate keccak hash for string with salt
Устаревший:
public static hash ( string $str, string $salt = '', boolean $plain = false ) : string
$str string Data
$salt string Salt
$plain boolean Is plain text?
Результат string

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

Returns string of pseudo random bytes
public static randomBytes ( integer $len, callable $cb, integer $pri, boolean $hang = false ) : integer
$len integer Length of desired string
$cb callable Callback
$pri integer Priority of EIO operation
$hang boolean If true, we shall use /dev/random instead of /dev/urandom and it may cause a delay
Результат integer

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

Returns array of pseudo random integers of machine-dependent size
public static randomInts ( integer $numInts, callable $cb, integer $pri, boolean $hang = false ) : integer
$numInts integer Number of integers
$cb callable Callback
$pri integer Priority of EIO operation
$hang boolean If true, we shall use /dev/random instead of /dev/urandom and it may cause a delay
Результат integer

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

Returns array of pseudo random 32-bit integers
public static randomInts32 ( integer $numInts, callable $cb, integer $pri, boolean $hang = false ) : integer
$numInts integer Number of integers
$cb callable Callback
$pri integer Priority of EIO operation
$hang boolean If true, we shall use /dev/random instead of /dev/urandom and it may cause a delay
Результат integer

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

Returns string of pseudo random characters
public static randomString ( integer $len = null, string $chars = null, callable $cb = null, integer $pri, boolean $hang = false ) : string
$len integer Length of desired string
$chars string String of allowed characters
$cb callable Callback
$pri integer Priority of EIO operation
$hang boolean If true, we shall use /dev/random instead of /dev/urandom and it may cause a delay
Результат string

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

Returns the character at index $idx in $str in constant time
public static stringIdx ( string $str, integer $idx ) : string
$str string String
$idx integer Index
Результат string