def identiconize(address): size = 48 # If you include another identicon library, please generate an # example identicon with the following md5 hash: # 3fd4bf901b9d4ea1394f0fb358725b28 try: identicon_lib = shared.config.get('bitmessagesettings', 'identiconlib') except: # default to qidenticon_two_x identicon_lib = 'qidenticon_two_x' # As an 'identiconsuffix' you could put "@bitmessge.ch" or "@bm.addr" to make it compatible with other identicon generators. (Note however, that E-Mail programs might convert the BM-address to lowercase first.) # It can be used as a pseudo-password to salt the generation of the identicons to decrease the risk # of attacks where someone creates an address to mimic someone else's identicon. identiconsuffix = shared.config.get('bitmessagesettings', 'identiconsuffix') if not shared.config.getboolean('bitmessagesettings', 'useidenticons'): idcon = QtGui.QIcon() return idcon if (identicon_lib[:len('qidenticon')] == 'qidenticon'): # print identicon_lib # originally by: # :Author:Shin Adachi <*****@*****.**> # Licesensed under FreeBSD License. # stripped from PIL and uses QT instead (by sendiulo, same license) import qidenticon hash = hashlib.md5(addBMIfNotPresent(address)+identiconsuffix).hexdigest() use_two_colors = (identicon_lib[:len('qidenticon_two')] == 'qidenticon_two') opacity = int(not((identicon_lib == 'qidenticon_x') | (identicon_lib == 'qidenticon_two_x') | (identicon_lib == 'qidenticon_b') | (identicon_lib == 'qidenticon_two_b')))*255 penwidth = 0 image = qidenticon.render_identicon(int(hash, 16), size, use_two_colors, opacity, penwidth) # filename = './images/identicons/'+hash+'.png' # image.save(filename) idcon = QtGui.QIcon() idcon.addPixmap(image, QtGui.QIcon.Normal, QtGui.QIcon.Off) return idcon elif identicon_lib == 'pydenticon': # print identicon_lib # Here you could load pydenticon.py (just put it in the "src" folder of your Bitmessage source) from pydenticon import Pydenticon # It is not included in the source, because it is licensed under GPLv3 # GPLv3 is a copyleft license that would influence our licensing # Find the source here: http://boottunes.googlecode.com/svn-history/r302/trunk/src/pydenticon.py # note that it requires PIL to be installed: http://www.pythonware.com/products/pil/ idcon_render = Pydenticon(addBMIfNotPresent(address)+identiconsuffix, size*3) rendering = idcon_render._render() data = rendering.convert("RGBA").tostring("raw", "RGBA") qim = QImage(data, size, size, QImage.Format_ARGB32) pix = QPixmap.fromImage(qim) idcon = QtGui.QIcon() idcon.addPixmap(pix, QtGui.QIcon.Normal, QtGui.QIcon.Off) return idcon
def identiconize(address): size = 48 # If you include another identicon library, please generate an # example identicon with the following md5 hash: # 3fd4bf901b9d4ea1394f0fb358725b28 try: identicon_lib = BMConfigParser().get('bitmessagesettings', 'identiconlib') except: # default to qidenticon_two_x identicon_lib = 'qidenticon_two_x' # As an 'identiconsuffix' you could put "@bitmessge.ch" or "@bm.addr" to make it compatible with other identicon generators. (Note however, that E-Mail programs might convert the BM-address to lowercase first.) # It can be used as a pseudo-password to salt the generation of the identicons to decrease the risk # of attacks where someone creates an address to mimic someone else's identicon. identiconsuffix = BMConfigParser().get('bitmessagesettings', 'identiconsuffix') if not BMConfigParser().getboolean('bitmessagesettings', 'useidenticons'): idcon = QtGui.QIcon() return idcon # originally by: # :Author:Shin Adachi <*****@*****.**> # Licesensed under FreeBSD License. # stripped from PIL and uses QT instead (by sendiulo, same license) hash = hashlib.md5(addBMIfNotPresent(address) + identiconsuffix).hexdigest() use_two_colors = ( identicon_lib[:len('qidenticon_two')] == 'qidenticon_two') opacity = int(not ((identicon_lib == 'qidenticon_x') | (identicon_lib == 'qidenticon_two_x') | (identicon_lib == 'qidenticon_b') | (identicon_lib == 'qidenticon_two_b'))) * 255 penwidth = 0 image = qidenticon.render_identicon(int(hash, 16), size, use_two_colors, opacity, penwidth) # filename = './images/identicons/'+hash+'.png' # image.save(filename) idcon = QtGui.QIcon() idcon.addPixmap(image, QtGui.QIcon.Normal, QtGui.QIcon.Off) return idcon
def identiconize(address): size = 48 # If you include another identicon library, please generate an # example identicon with the following md5 hash: # 3fd4bf901b9d4ea1394f0fb358725b28 try: identicon_lib = BMConfigParser().get('bitmessagesettings', 'identiconlib') except: # default to qidenticon_two_x identicon_lib = 'qidenticon_two_x' # As an 'identiconsuffix' you could put "@bitmessge.ch" or "@bm.addr" to make it compatible with other identicon generators. (Note however, that E-Mail programs might convert the BM-address to lowercase first.) # It can be used as a pseudo-password to salt the generation of the identicons to decrease the risk # of attacks where someone creates an address to mimic someone else's identicon. identiconsuffix = BMConfigParser().get('bitmessagesettings', 'identiconsuffix') if not BMConfigParser().getboolean('bitmessagesettings', 'useidenticons'): idcon = QtGui.QIcon() return idcon if (identicon_lib[:len('qidenticon')] == 'qidenticon'): # print identicon_lib # originally by: # :Author:Shin Adachi <*****@*****.**> # Licesensed under FreeBSD License. # stripped from PIL and uses QT instead (by sendiulo, same license) import qidenticon hash = hashlib.md5(addBMIfNotPresent(address) + identiconsuffix).hexdigest() use_two_colors = ( identicon_lib[:len('qidenticon_two')] == 'qidenticon_two') opacity = int(not ((identicon_lib == 'qidenticon_x') | (identicon_lib == 'qidenticon_two_x') | (identicon_lib == 'qidenticon_b') | (identicon_lib == 'qidenticon_two_b'))) * 255 penwidth = 0 image = qidenticon.render_identicon(int(hash, 16), size, use_two_colors, opacity, penwidth) # filename = './images/identicons/'+hash+'.png' # image.save(filename) idcon = QtGui.QIcon() idcon.addPixmap(image, QtGui.QIcon.Normal, QtGui.QIcon.Off) return idcon elif identicon_lib == 'pydenticon': # print identicon_lib # Here you could load pydenticon.py (just put it in the "src" folder of your Bitmessage source) from pydenticon import Pydenticon # It is not included in the source, because it is licensed under GPLv3 # GPLv3 is a copyleft license that would influence our licensing # Find the source here: http://boottunes.googlecode.com/svn-history/r302/trunk/src/pydenticon.py # note that it requires PIL to be installed: http://www.pythonware.com/products/pil/ idcon_render = Pydenticon( addBMIfNotPresent(address) + identiconsuffix, size * 3) rendering = idcon_render._render() data = rendering.convert("RGBA").tostring("raw", "RGBA") qim = QImage(data, size, size, QImage.Format_ARGB32) pix = QPixmap.fromImage(qim) idcon = QtGui.QIcon() idcon.addPixmap(pix, QtGui.QIcon.Normal, QtGui.QIcon.Off) return idcon