]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Helper/UrlHasher.php
Add Wallabag\CoreBundle\Helper\UrlHasher
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Helper / UrlHasher.php
diff --git a/src/Wallabag/CoreBundle/Helper/UrlHasher.php b/src/Wallabag/CoreBundle/Helper/UrlHasher.php
new file mode 100644 (file)
index 0000000..e44f219
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+namespace Wallabag\CoreBundle\Helper;
+
+/**
+ * Hash URLs for privacy and performance.
+ */
+class UrlHasher
+{
+    /** @var string */
+    const ALGORITHM = 'sha1';
+
+    /**
+     * @param string $url
+     *
+     * @return string hashed $url
+     */
+    public static function hashUrl(string $url)
+    {
+        return hash(static::ALGORITHM, $url);
+    }
+}