src/Encryption/FastEncrypt.php
/**
	 * Generates a key to use for encryption.
	 *
	 * @param $length
	 * @return string Encryption key containing $length number of characters.
	 */
Generates a key to use for encryption.
@param $length
@return string Encryption key containing $length number of characters.
Generates a key to use for encryption . @param $length @return string Encryption key containing $length number of characters .
private static function generateKey($length = 32) {
		if (env('APP_SECRET')) {
			return substr(hash('sha256', sprintf('FE:%s', env('APP_SECRET'))), 0, $length);
		}
		$base = substr(md5(__DIR__), 0, 10);
		if (isset($_SERVER['PATH'])) $base .= substr(md5($_SERVER['PATH']), 2, 8);
		if (isset($_SERVER['TMP'])) $base .= substr(md5($_SERVER['TMP']), 2, 8);
		if (function_exists('curl_version')) $base .= substr(md5(curl_version()['version_number']), 2, 4);
		if (@ini_get('max_execution_time')) $base .= substr(md5(ini_get('max_execution_time')), 2, 4);
		if (@ini_get('log_errors_max_len')) $base .= substr(md5(ini_get('log_errors_max_len')), 2, 4);
		$base .= md5($base);
		$first = substr(md5(substr($base, 0, (strlen($base) / 2))), 0, floor($length / 2));
		$last = substr(md5(substr($base, (strlen($base) / 2))), 0, ceil($length / 2));
		return $first . $last;
	}
private static function generateKey ( $ length = 32 ) { if ( env ( 'APP_SECRET' ) ) { return substr ( hash ( 'sha256' , sprintf ( 'FE:%s' , env ( 'APP_SECRET' ) ) ) , 0 , $ length ) ; } $ base = substr ( md5 ( __DIR__ ) , 0 , 10 ) ; if ( isset ( $ _SERVER [ 'PATH' ] ) ) $ base .= substr ( md5 ( $ _SERVER [ 'PATH' ] ) , 2 , 8 ) ; if ( isset ( $ _SERVER [ 'TMP' ] ) ) $ base .= substr ( md5 ( $ _SERVER [ 'TMP' ] ) , 2 , 8 ) ; if ( function_exists ( 'curl_version' ) ) $ base .= substr ( md5 ( curl_version ( ) [ 'version_number' ] ) , 2 , 4 ) ; if ( @ ini_get ( 'max_execution_time' ) ) $ base .= substr ( md5 ( ini_get ( 'max_execution_time' ) ) , 2 , 4 ) ; if ( @ ini_get ( 'log_errors_max_len' ) ) $ base .= substr ( md5 ( ini_get ( 'log_errors_max_len' ) ) , 2 , 4 ) ; $ base .= md5 ( $ base ) ; $ first = substr ( md5 ( substr ( $ base , 0 , ( strlen ( $ base ) / 2 ) ) ) , 0 , floor ( $ length / 2 ) ) ; $ last = substr ( md5 ( substr ( $ base , ( strlen ( $ base ) / 2 ) ) ) , 0 , ceil ( $ length / 2 ) ) ; return $ first . $ last ; }
Generates a key to use for encryption.
Generates a key to use for encryption .