ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilBasePasswordEncoder.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
29 private const MAX_PASSWORD_LENGTH = 4096;
30
40 protected function comparePasswords(string $knownString, string $userString): bool
41 {
42 $knownString .= chr(0);
43 $userString .= chr(0);
44
45 $known_string_length = strlen($knownString);
46 $user_string_length = strlen($userString);
47
48 $result = $known_string_length - $user_string_length;
49
50 for ($i = 0; $i < $user_string_length; ++$i) {
51 $result |= (ord($knownString[$i % $known_string_length]) ^ ord($userString[$i]));
52 }
53
54 return 0 === $result;
55 }
56
57 protected function isPasswordTooLong(string $password): bool
58 {
59 return strlen($password) > self::MAX_PASSWORD_LENGTH;
60 }
61
62 public function isSupportedByRuntime(): bool
63 {
64 return true;
65 }
66
67 public function requiresSalt(): bool
68 {
69 return false;
70 }
71
72 public function requiresReencoding(string $encoded): bool
73 {
74 return false;
75 }
76}
requiresSalt()
Returns whether the encoder requires a salt.
isSupportedByRuntime()
Returns whether the encoder is supported by the runtime (PHP, HHVM, ...)
comparePasswords(string $knownString, string $userString)
Compares two passwords.
requiresReencoding(string $encoded)
Returns whether the encoded password needs to be re-encoded.