HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: /home/mirz4654/.trash/vibes/includes/system/class-hash.php
<?php
/**
 * Hash handling
 *
 * Handles all hash operations and detection.
 *
 * @package System
 * @author  Pierre Lannoy <https://pierre.lannoy.fr/>.
 * @since   1.0.0
 */

namespace Vibes\System;

/**
 * Define the hash functionality.
 *
 * Handles all hash operations and detection.
 *
 * @package System
 * @author  Pierre Lannoy <https://pierre.lannoy.fr/>.
 * @since   1.0.0
 */
class Hash {

	/**
	 * Algo availability.
	 *
	 * @since  1.0.0
	 * @var    array    $x_available    Is MD5 available?
	 */
	private static $x_available = [];

	/**
	 * SHA1 availability.
	 *
	 * @since  1.0.0
	 * @var    boolean    $sha1_available    Is SHA1 available?
	 */
	private static $sha1_available = false;

	/**
	 * SHA-256 availability.
	 *
	 * @since  1.0.0
	 * @var    boolean    $sha256_available    Is SHA-256 available?
	 */
	private static $sha256_available = false;

	/**
	 * Initializes the class and set its properties.
	 *
	 * @since 1.0.0
	 */
	public function __construct() {
	}

	/**
	 * Static initialization.
	 *
	 * @since  1.0.0
	 */
	public static function init() {
		self::$x_available      = hash_algos();
		self::$sha1_available   = in_array( 'sha1', self::$x_available );
		self::$sha256_available = in_array( 'sha256', self::$x_available );
	}

	/**
	 * Simple hashing function.
	 *
	 * @param   string  $secret     String to hash.
	 * @param   boolean $markup     Optional. With {}.
	 * @return  string  The hashed string.
	 * @since  1.0.0
	 */
	public static function simple_hash( $secret, $markup = true ) {
		if ( self::$sha256_available ) {
			$result = hash( 'sha256', (string) $secret );
		} elseif ( self::$sha1_available ) {
			$result = hash( 'sha1', (string) $secret );
		} else {
			$result = hash( 'md5', (string) $secret );
		}
		if ( $markup ) {
			$result = '{' . $result . '}';
		}
		return $result;
	}

}

Hash::init();