mirror of
https://github.com/wallabag/wallabag.git
synced 2025-08-31 18:31:02 +00:00
Change the way to define algorithm for hashing url
This commit is contained in:
parent
4a5516376b
commit
0132ccd2a2
3 changed files with 12 additions and 12 deletions
|
@ -7,16 +7,17 @@ namespace Wallabag\CoreBundle\Helper;
|
|||
*/
|
||||
class UrlHasher
|
||||
{
|
||||
/** @var string */
|
||||
const ALGORITHM = 'sha1';
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* Hash the given url using the given algorithm.
|
||||
* Hashed url are faster to be retrieved in the database than the real url.
|
||||
*
|
||||
* @return string hashed $url
|
||||
* @param string $url
|
||||
* @param string $algorithm
|
||||
*
|
||||
* @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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue