Sfoglia il codice sorgente

Add custom identicon preprocessor

Daniel Supernault 7 anni fa
parent
commit
d9db890514
1 ha cambiato i file con 21 aggiunte e 0 eliminazioni
  1. 21 0
      app/Util/Identicon/Preprocessor/HashPreprocessor.php

+ 21 - 0
app/Util/Identicon/Preprocessor/HashPreprocessor.php

@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Util\Identicon\Preprocessor;
+
+class HashPreprocessor implements \Bitverse\Identicon\Preprocessor\PreprocessorInterface
+{
+    protected $algo = 'sha256';
+
+    public function __construct($algo = 'sha256')
+    {
+      $this->algo = $algo;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public function process($string)
+    {
+        return hash($this->algo, $string);
+    }
+}