PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
defender-security / src / component / altcha / Hasher / class-algorithm.php

class-algorithm.php in Defender Security – Malware Scanner, Login Security & Firewall 6.3.0, at src/component/altcha/Hasher/class-algorithm.php

52 lines 1013 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The Algorithm class for hashing algorithms.
4 *
5 * @package WP_Defender\Component\Altcha\Hasher
6 */
7
8 namespace WP_Defender\Component\Altcha\Hasher;
9
10 /**
11 * Class Algorithm
12 */
13 final class Algorithm {
14 public const SHA1 = 'SHA-1';
15 public const SHA256 = 'SHA-256';
16 public const SHA512 = 'SHA-512';
17
18 /**
19 * Tries to check if the given value is a valid algorithm.
20 *
21 * @param string|null $value The algorithm value.
22 *
23 * @return string|null The valid algorithm or null if invalid.
24 */
25 public static function try_from( ?string $value ): ?string {
26 if ( null === $value ) {
27 return null;
28 }
29
30 return self::is_valid( $value ) ? $value : null;
31 }
32
33 /**
34 * Checks if the given value is a valid algorithm.
35 *
36 * @param string $value The algorithm value.
37 *
38 * @return bool True if valid, false otherwise.
39 */
40 public static function is_valid( string $value ): bool {
41 return in_array(
42 $value,
43 array(
44 self::SHA1,
45 self::SHA256,
46 self::SHA512,
47 ),
48 true
49 );
50 }
51 }
52