Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Static Public Member Functions | Data Fields | Static Protected Member Functions | Static Protected Attributes
Zend_Crypt Class Reference
Inheritance diagram for Zend_Crypt:
Zend_Crypt_Hmac

Static Public Member Functions

static hash ($algorithm, $data, $binaryOutput=false)
 

Data Fields

const TYPE_OPENSSL = 'openssl'
 
const TYPE_HASH = 'hash'
 
const TYPE_MHASH = 'mhash'
 

Static Protected Member Functions

static _detectHashSupport ($algorithm)
 
static _digestHash ($algorithm, $data, $binaryOutput)
 
static _digestMhash ($algorithm, $data, $binaryOutput)
 
static _digestOpenssl ($algorithm, $data, $binaryOutput)
 

Static Protected Attributes

static $_type = null
 
static $_supportedAlgosOpenssl
 
static $_supportedAlgosMhash
 

Detailed Description

Definition at line 28 of file Crypt.php.

Member Function Documentation

◆ _detectHashSupport()

static _detectHashSupport (   $algorithm)
staticprotected
Parameters
string$algorithm
Exceptions
Zend_Crypt_Exception
See also
Zend_Crypt_Exception

Definition at line 97 of file Crypt.php.

98  {
99  if (function_exists('hash')) {
100  self::$_type = self::TYPE_HASH;
101  if (in_array($algorithm, hash_algos())) {
102  return;
103  }
104  }
105  if (function_exists('mhash')) {
106  self::$_type = self::TYPE_MHASH;
107  if (in_array($algorithm, self::$_supportedAlgosMhash)) {
108  return;
109  }
110  }
111  if (function_exists('openssl_digest')) {
112  if ($algorithm == 'ripemd160') {
113  $algorithm = 'rmd160';
114  }
115  self::$_type = self::TYPE_OPENSSL;
116  if (in_array($algorithm, self::$_supportedAlgosOpenssl)) {
117  return;
118  }
119  }
123  #require_once 'Zend/Crypt/Exception.php';
124  throw new Zend_Crypt_Exception('\'' . $algorithm . '\' is not supported by any available extension or native function');
125  }
const TYPE_HASH
Definition: Crypt.php:32
const TYPE_MHASH
Definition: Crypt.php:33
const TYPE_OPENSSL
Definition: Crypt.php:31

◆ _digestHash()

static _digestHash (   $algorithm,
  $data,
  $binaryOutput 
)
staticprotected
Parameters
string$algorithm
string$data
bool$binaryOutput
Returns
string

Definition at line 133 of file Crypt.php.

134  {
135  return hash($algorithm, $data, $binaryOutput);
136  }
static hash($algorithm, $data, $binaryOutput=false)
Definition: Crypt.php:81

◆ _digestMhash()

static _digestMhash (   $algorithm,
  $data,
  $binaryOutput 
)
staticprotected
Parameters
string$algorithm
string$data
bool$binaryOutput
Returns
string

Definition at line 144 of file Crypt.php.

145  {
146  $constant = constant('MHASH_' . strtoupper($algorithm));
147  $binary = mhash($constant, $data);
148  if ($binaryOutput) {
149  return $binary;
150  }
151  return bin2hex($binary);
152  }

◆ _digestOpenssl()

static _digestOpenssl (   $algorithm,
  $data,
  $binaryOutput 
)
staticprotected
Parameters
string$algorithm
string$data
bool$binaryOutput
Returns
string

Definition at line 160 of file Crypt.php.

161  {
162  if ($algorithm == 'ripemd160') {
163  $algorithm = 'rmd160';
164  }
165  return openssl_digest($data, $algorithm, $binaryOutput);
166  }

◆ hash()

static hash (   $algorithm,
  $data,
  $binaryOutput = false 
)
static
Parameters
string$algorithm
string$data
bool$binaryOutput
Returns
unknown

Definition at line 81 of file Crypt.php.

82  {
83  $algorithm = strtolower($algorithm);
84  if (function_exists($algorithm)) {
85  return $algorithm($data, $binaryOutput);
86  }
87  self::_detectHashSupport($algorithm);
88  $supportedMethod = '_digest' . ucfirst(self::$_type);
89  $result = self::$supportedMethod($algorithm, $data, $binaryOutput);
90  return $result;
91  }
static _detectHashSupport($algorithm)
Definition: Crypt.php:97

Field Documentation

◆ $_supportedAlgosMhash

$_supportedAlgosMhash
staticprotected
Initial value:
= array(
'adler32',
'crc32',
'crc32b',
'gost',
'haval128',
'haval160',
'haval192',
'haval256',
'md4',
'md5',
'ripemd160',
'sha1',
'sha256',
'tiger',
'tiger128',
'tiger160'
)

Definition at line 56 of file Crypt.php.

◆ $_supportedAlgosOpenssl

$_supportedAlgosOpenssl
staticprotected
Initial value:
= array(
'md2',
'md4',
'mdc2',
'rmd160',
'sha',
'sha1',
'sha224',
'sha256',
'sha384',
'sha512'
)

Definition at line 40 of file Crypt.php.

◆ $_type

$_type = null
staticprotected

Definition at line 35 of file Crypt.php.

◆ TYPE_HASH

const TYPE_HASH = 'hash'

Definition at line 32 of file Crypt.php.

◆ TYPE_MHASH

const TYPE_MHASH = 'mhash'

Definition at line 33 of file Crypt.php.

◆ TYPE_OPENSSL

const TYPE_OPENSSL = 'openssl'

Definition at line 31 of file Crypt.php.


The documentation for this class was generated from the following file: