<?php
namespace Core;

class Hash
{
	public static function make($string, $salt = '')
	{
		// return hash('sha256', $string . $salt);
		// return password_hash($string, PASSWORD_BCRYPT);
		return crypt($string, $salt);
	}

	public static function salt()
	{
		// return mcrypt_create_iv($length);
		return uniqid(mt_rand());
	}

	public static function unique()
	{
		return self::make(uniqid());
	}

	public static function compare($string, $salt, $hash)
	{
		// return (Hash::make($string, $salt) === $hash) ? true : false;
		// return password_verify($string, $hash);
		return hash_equals($hash, Hash::make($string, $salt));
	}
}
