mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-31 18:31:02 +00:00
Merge pull request #3944 from shtrom/always-hash-exists-url
Always hash exists url
This commit is contained in:
commit
2cbee36a01
5 changed files with 84 additions and 51 deletions
23
src/Wallabag/CoreBundle/Helper/UrlHasher.php
Normal file
23
src/Wallabag/CoreBundle/Helper/UrlHasher.php
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Wallabag\CoreBundle\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 $url
|
||||
* @param string $algorithm
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function hashUrl(string $url, $algorithm = 'sha1')
|
||||
{
|
||||
return hash($algorithm, urldecode($url));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue