From 0132ccd2a2e73a831fa198940c369bcdd5249e8b Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 24 May 2019 15:15:12 +0200 Subject: Change the way to define algorithm for hashing url --- src/Wallabag/CoreBundle/Helper/UrlHasher.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/Wallabag/CoreBundle/Helper/UrlHasher.php') diff --git a/src/Wallabag/CoreBundle/Helper/UrlHasher.php b/src/Wallabag/CoreBundle/Helper/UrlHasher.php index e44f219a..d123eaba 100644 --- a/src/Wallabag/CoreBundle/Helper/UrlHasher.php +++ b/src/Wallabag/CoreBundle/Helper/UrlHasher.php @@ -7,16 +7,17 @@ namespace Wallabag\CoreBundle\Helper; */ class UrlHasher { - /** @var string */ - const ALGORITHM = 'sha1'; - /** + * Hash the given url using the given algorithm. + * Hashed url are faster to be retrieved in the database than the real url. + * * @param string $url + * @param string $algorithm * - * @return string hashed $url + * @return string */ - public static function hashUrl(string $url) + public static function hashUrl(string $url, $algorithm = 'sha1') { - return hash(static::ALGORITHM, $url); + return hash($algorithm, urldecode($url)); } } -- cgit v1.2.3