ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilMd5PasswordEncoder.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
4require_once 'Services/Password/classes/class.ilBasePasswordEncoder.php';
5
15{
20 public function encodePassword(string $raw, string $salt) : string
21 {
22 if ($this->isPasswordTooLong($raw)) {
23 throw new ilPasswordException('Invalid password.');
24 }
25
26 return md5($raw);
27 }
28
33 public function isPasswordValid(string $encoded, string $raw, string $salt) : bool
34 {
35 return !$this->isPasswordTooLong($raw) && $this->comparePasswords($encoded, $this->encodePassword($raw, $salt));
36 }
37
41 public function getName() : string
42 {
43 return 'md5';
44 }
45}
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.
encodePassword(string $raw, string $salt)
@inheritDoc
isPasswordValid(string $encoded, string $raw, string $salt)
@inheritDoc
Class for user password exception handling in ILIAS.