• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lonnieezell / myth-auth / 3871728138

pending completion
3871728138

Pull #587

github

GitHub
Merge a8c192379 into da3522738
Pull Request #587: Update development kit

815 of 2284 relevant lines covered (35.68%)

8.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.68
/src/Password.php
1
<?php
2

3
namespace Myth\Auth;
4

5
/**
6
 * Class Password
7
 */
8
class Password
9
{
10
    /**
11
     * @param string $password Password
12
     */
13
    public static function hash(string $password): string
14
    {
15
        $config = config('Auth');
102✔
16

17
        if (
18
            (defined('PASSWORD_ARGON2I') && $config->hashAlgorithm === PASSWORD_ARGON2I)
102✔
19
            || (defined('PASSWORD_ARGON2ID') && $config->hashAlgorithm === PASSWORD_ARGON2ID)
102✔
20
        ) {
21
            $hashOptions = [
×
22
                'memory_cost' => $config->hashMemoryCost,
×
23
                'time_cost'   => $config->hashTimeCost,
×
24
                'threads'     => $config->hashThreads,
×
25
            ];
×
26
        } else {
27
            $hashOptions = [
102✔
28
                'cost' => $config->hashCost,
102✔
29
            ];
102✔
30
        }
31

32
        return password_hash(
102✔
33
            self::preparePassword($password),
102✔
34
            $config->hashAlgorithm,
102✔
35
            $hashOptions
102✔
36
        );
102✔
37
    }
38

39
    /**
40
     * @param string $password Password
41
     * @param string $hash     Hash
42
     */
43
    public static function verify(string $password, string $hash): bool
44
    {
45
        return password_verify(self::preparePassword($password), $hash);
8✔
46
    }
47

48
    /**
49
     * @param string     $hash    Hash
50
     * @param int|string $algo    Hash algorithm
51
     * @param array      $options Options
52
     */
53
    public static function needsRehash(string $hash, $algo, array $options = []): bool
54
    {
55
        return password_needs_rehash($hash, $algo, $options);
6✔
56
    }
57

58
    /**
59
     * @param string $password Password
60
     */
61
    protected static function preparePassword(string $password): string
62
    {
63
        return base64_encode(hash('sha384', $password, true));
103✔
64
    }
65
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc