ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilBasePasswordEncoder.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9abstract class ilBasePasswordEncoder implements ilPasswordEncoder
10{
12 const MAX_PASSWORD_LENGTH = 4096;
13
23 protected function comparePasswords(string $knownString, string $userString) : bool
24 {
25 $knownString .= chr(0);
26 $userString .= chr(0);
27
28 $known_string_length = strlen($knownString);
29 $user_string_length = strlen($userString);
30
31 $result = $known_string_length - $user_string_length;
32
33 for ($i = 0; $i < $user_string_length; $i++) {
34 $result |= (ord($knownString[$i % $known_string_length]) ^ ord($userString[$i]));
35 }
36
37 // They are only identical strings if $result is exactly 0...
38 return 0 === $result;
39 }
40
46 protected function isPasswordTooLong(string $password) : bool
47 {
48 return strlen($password) > self::MAX_PASSWORD_LENGTH;
49 }
50
54 public function isSupportedByRuntime() : bool
55 {
56 return true;
57 }
58
62 public function requiresSalt() : bool
63 {
64 return false;
65 }
66
70 public function requiresReencoding(string $encoded) : bool
71 {
72 return false;
73 }
74}
$result
An exception for terminatinating execution or to throw for unit testing.
isPasswordTooLong(string $password)
Checks if the password is too long.
comparePasswords(string $knownString, string $userString)
Compares two passwords.
requiresReencoding(string $encoded)
@inheritDoc
$password
Definition: cron.php:14
$i
Definition: metadata.php:24