Lines
100.00%
12 / 12
Methods
100.00%
5 / 5
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| encrypt | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [phpMyFAQ\Encryption] __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| [phpMyFAQ\Encryption] getInstance | 100.00% | 7 / 7 | 100.00% | 1 / 1 | 3 | ||
| [phpMyFAQ\Encryption] error | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | ||
| [phpMyFAQ\Encryption] setSalt | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| 30 | class Hash extends Encryption | |
| 31 | { | |
| 32 | /** | |
| 33 | * encrypts the string str and returns the result. | |
| 34 | * | |
| 35 | * @param string $password String | |
| 36 | */ | |
| 37 | #[\Override] | |
| 38 | public function encrypt(#[SensitiveParameter] string $password): string | |
| 39 | { | |
| 40 | return hash('sha256', $password . $this->salt); | |
| 41 | } | |
| 42 | } |
Inherited from phpMyFAQ\Encryption
| 47 | private function __construct( | |
| 48 | protected Configuration $configuration, | |
| 49 | ) { | |
| 50 | } |
| 62 | public static function getInstance(string $encType, Configuration $configuration): Encryption | |
| 63 | { | |
| 64 | $self = new self($configuration); | |
| 65 | $encType = ucfirst(strtolower($encType)); | |
| 66 | ||
| 67 | $encClass = 'phpMyFAQ\\EncryptionTypes\\' . $encType; | |
| 68 | if (!class_exists($encClass) || !is_subclass_of($encClass, self::class)) { | |
| 69 | $self->errors[] = self::PMF_ERROR_USER_NO_ENCTYPE; | |
| 70 | ||
| 71 | return $self; | |
| 72 | } | |
| 73 | ||
| 74 | return new $encClass($configuration); | |
| 75 | } |
| 92 | public function error(): string | |
| 93 | { | |
| 94 | return $this->errors !== [] ? implode(PHP_EOL, $this->errors) . PHP_EOL : ''; | |
| 95 | } |
| 100 | public function setSalt(string $login): Encryption | |
| 101 | { | |
| 102 | $this->salt = (string) $this->configuration->get(item: 'security.salt') . $login; | |
| 103 | return $this; | |
| 104 | } |