From 4a5516376bf4c8b0cdc1e81d24ce1cca68425785 Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Fri, 10 May 2019 22:07:55 +1000 Subject: Add Wallabag\CoreBundle\Helper\UrlHasher Signed-off-by: Olivier Mehani --- src/Wallabag/CoreBundle/Helper/UrlHasher.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/Wallabag/CoreBundle/Helper/UrlHasher.php (limited to 'src/Wallabag/CoreBundle/Helper') diff --git a/src/Wallabag/CoreBundle/Helper/UrlHasher.php b/src/Wallabag/CoreBundle/Helper/UrlHasher.php new file mode 100644 index 00000000..e44f219a --- /dev/null +++ b/src/Wallabag/CoreBundle/Helper/UrlHasher.php @@ -0,0 +1,22 @@ + 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') 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