Browse Source

Use pydenticon5 instead of pydenticon

master
Johann Schmitz 1 year ago
parent
commit
241a3277bc
Signed by: Johann Schmitz <johann@j-schmitz.net> GPG Key ID: A084064277C501ED
2 changed files with 12 additions and 16 deletions
  1. 11
    15
      esgp/ui.py
  2. 1
    1
      requirements.txt

+ 11
- 15
esgp/ui.py View File

@@ -15,9 +15,9 @@
15 15
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 16
 import hashlib
17 17
 import logging
18
+from io import BytesIO
18 19
 from urllib.parse import urlparse
19 20
 
20
-import pydenticon
21 21
 import supergenpass
22 22
 from PyQt5.QtCore import QEvent, Qt
23 23
 from PyQt5.QtGui import QPixmap, QIntValidator, QIcon
@@ -25,6 +25,7 @@ from PyQt5.QtWidgets import QVBoxLayout, QLineEdit, QHBoxLayout, QRadioButton, Q
25 25
     QFrame, QDialog, QApplication
26 26
 
27 27
 from esgp.settings import SettingsDialog
28
+from pydenticon5 import Pydenticon5
28 29
 
29 30
 logger = logging.getLogger(__name__)
30 31
 
@@ -185,22 +186,17 @@ class MainWindow(QDialog):
185 186
         if not pwd:
186 187
             return
187 188
         
188
-        for i in range(0, 4):
189
+        s = pwd
190
+        for i in range(0, 5):
189 191
             h = self.get_digest()()
190
-            h.update(pwd.encode('utf-8'))
191
-            pwd = h.hexdigest()
192
-
193
-        foreground = ["rgb(45,79,255)",
194
-                      "rgb(254,180,44)",
195
-                      "rgb(226,121,234)",
196
-                      "rgb(30,179,253)",
197
-                      "rgb(232,77,65)",
198
-                      "rgb(49,203,115)",
199
-                      "rgb(141,69,170)"]
200
-        
192
+            h.update(s.encode('utf-8'))
193
+            s = h.hexdigest()
194
+
201 195
         img = QPixmap()
202
-        identicon_generator = pydenticon.Generator(5, 5, digest=self.get_digest(), foreground=foreground, background="rgba(224,224,224,0)")
203
-        img.loadFromData(identicon_generator.generate(pwd, 16, 16))
196
+        identicon = Pydenticon5().draw(s, 16)
197
+        img_bytes = BytesIO()
198
+        identicon.save(img_bytes, 'PNG')
199
+        img.loadFromData(img_bytes.getvalue())
204 200
         self.identicon_label.setVisible(True)
205 201
         self.identicon_label.setPixmap(img)
206 202
 

+ 1
- 1
requirements.txt View File

@@ -1,4 +1,4 @@
1 1
 daiquiri
2 2
 PyQt5
3
-pydenticon
4 3
 -e git+https://github.com/vianney/python-supergenpass#egg=supergenpass
4
+-e git+https://git.ercpe.de/ercpe/pydenticon5.git#egg=pydenticon5

Loading…
Cancel
Save