mirror of
https://github.com/wallabag/wallabag.git
synced 2024-09-27 05:50:02 +00:00
22 lines
453 B
PHP
22 lines
453 B
PHP
<?php
|
|
|
|
namespace Wallabag\Helper;
|
|
|
|
/**
|
|
* Hash URLs for privacy and performance.
|
|
*/
|
|
class UrlHasher
|
|
{
|
|
/**
|
|
* Hash the given url using the given algorithm.
|
|
* Hashed url are faster to be retrieved in the database than the real url.
|
|
*
|
|
* @param string $algorithm
|
|
*
|
|
* @return string
|
|
*/
|
|
public static function hashUrl(string $url, $algorithm = 'sha1')
|
|
{
|
|
return hash($algorithm, urldecode($url));
|
|
}
|
|
}
|