|
@@ 58-81 (lines=24) @@
|
| 55 |
|
|
| 56 |
|
public function crypt( $password ) { |
| 57 |
|
$lastHash = $password; |
| 58 |
|
foreach ( $this->config['types'] as $i => $type ) { |
| 59 |
|
// Construct pseudo-hash based on params and arguments |
| 60 |
|
/** @var ParameterizedPassword $passObj */ |
| 61 |
|
$passObj = $this->factory->newFromType( $type ); |
| 62 |
|
|
| 63 |
|
$params = ''; |
| 64 |
|
$args = ''; |
| 65 |
|
if ( $this->params[$i] !== '' ) { |
| 66 |
|
$params = $this->params[$i] . $passObj->getDelimiter(); |
| 67 |
|
} |
| 68 |
|
if ( isset( $this->args[$i] ) && $this->args[$i] !== '' ) { |
| 69 |
|
$args = $this->args[$i] . $passObj->getDelimiter(); |
| 70 |
|
} |
| 71 |
|
$existingHash = ":$type:" . $params . $args . $this->hash; |
| 72 |
|
|
| 73 |
|
// Hash the last hash with the next type in the layer |
| 74 |
|
$passObj = $this->factory->newFromCiphertext( $existingHash ); |
| 75 |
|
$passObj->crypt( $lastHash ); |
| 76 |
|
|
| 77 |
|
// Move over the params and args |
| 78 |
|
$this->params[$i] = implode( $passObj->getDelimiter(), $passObj->params ); |
| 79 |
|
$this->args[$i] = implode( $passObj->getDelimiter(), $passObj->args ); |
| 80 |
|
$lastHash = $passObj->hash; |
| 81 |
|
} |
| 82 |
|
|
| 83 |
|
$this->hash = $lastHash; |
| 84 |
|
} |
|
@@ 109-136 (lines=28) @@
|
| 106 |
|
$lastHash = $passObj->hash; |
| 107 |
|
|
| 108 |
|
// Layer the remaining types |
| 109 |
|
foreach ( $this->config['types'] as $i => $type ) { |
| 110 |
|
if ( $i == 0 ) { |
| 111 |
|
continue; |
| 112 |
|
}; |
| 113 |
|
|
| 114 |
|
// Construct pseudo-hash based on params and arguments |
| 115 |
|
/** @var ParameterizedPassword $passObj */ |
| 116 |
|
$passObj = $this->factory->newFromType( $type ); |
| 117 |
|
|
| 118 |
|
$params = ''; |
| 119 |
|
$args = ''; |
| 120 |
|
if ( $this->params[$i] !== '' ) { |
| 121 |
|
$params = $this->params[$i] . $passObj->getDelimiter(); |
| 122 |
|
} |
| 123 |
|
if ( isset( $this->args[$i] ) && $this->args[$i] !== '' ) { |
| 124 |
|
$args = $this->args[$i] . $passObj->getDelimiter(); |
| 125 |
|
} |
| 126 |
|
$existingHash = ":$type:" . $params . $args . $this->hash; |
| 127 |
|
|
| 128 |
|
// Hash the last hash with the next type in the layer |
| 129 |
|
$passObj = $this->factory->newFromCiphertext( $existingHash ); |
| 130 |
|
$passObj->crypt( $lastHash ); |
| 131 |
|
|
| 132 |
|
// Move over the params and args |
| 133 |
|
$this->params[$i] = implode( $passObj->getDelimiter(), $passObj->params ); |
| 134 |
|
$this->args[$i] = implode( $passObj->getDelimiter(), $passObj->args ); |
| 135 |
|
$lastHash = $passObj->hash; |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
$this->hash = $lastHash; |
| 139 |
|
} |