Identicons #542

Merged
Atheros1 merged 26 commits from master into master 2013-11-02 23:16:08 +01:00
Showing only changes of commit a9fb87173f - Show all commits

View File

@ -53,7 +53,7 @@ import hashlib
# load identicon code # load identicon code
# :Author:Shin Adachi <shn@glucose.jp> # :Author:Shin Adachi <shn@glucose.jp>
# Licesensed under FreeBSD License. # Licesensed under FreeBSD License.
# import identicon import identicon
# usage: identicon.render_identicon(code, size) # usage: identicon.render_identicon(code, size)
# requires PIL # requires PIL
@ -75,27 +75,25 @@ def identiconize(address):
idcon = QtGui.QIcon() idcon = QtGui.QIcon()
return idcon return idcon
suffix = "" # here you could put "@bitmessge.ch" or "@bm.addr" to make it compatible with other identicon generators
# instead, you could also use a pseudo-password to salt the generation of the identicons
# Attacks where someone creates an address to mimic someone else's identicon should be impossible then
# i think it should generate a random string by default
# hash = hashlib.md5(addBMIfNotPresent(address)+suffix).hexdigest()[:8]
# print hash
##japanese code
# idcon_render = identicon.render_identicon(int(hash, 16), 8)
# idcon_render.save('images/'+hash+'.png')
# im = idcon_render
# http://qt-project.org/forums/viewthread/5866
# from PIL import Image
# from PyQt4.QtGui import QImage, QImageReader, QLabel, QPixmap, QApplication
str_broadcast_subscribers = '[Broadcast subscribers]' str_broadcast_subscribers = '[Broadcast subscribers]'
if address == str_broadcast_subscribers: if address == str_broadcast_subscribers:
idcon = QtGui.QIcon(":/newPrefix/images/can-icon-24px.png") idcon = QtGui.QIcon(":/newPrefix/images/can-icon-24px.png")
return idcon return idcon
# PHP-like code suffix = "asdf"
# here you could put "@bitmessge.ch" or "@bm.addr" to make it compatible with other identicon generators
# instead, you could also use a pseudo-password to salt the generation of the identicons
# Attacks where someone creates an address to mimic someone else's identicon should be impossible then
# i think it should generate a random string by default
if True: # identicon.py
hash = hashlib.md5(addBMIfNotPresent(address)+suffix).hexdigest()
idcon_render = identicon.render_identicon(int(hash, 16), 48)
image = idcon_render
# http://qt-project.org/forums/viewthread/5866
# from PIL import Image
# from PyQt4.QtGui import QImage, QImageReader, QLabel, QPixmap, QApplication
else: # pydenticon.py
idcon_render = Pydenticon(addBMIfNotPresent(address)+suffix) idcon_render = Pydenticon(addBMIfNotPresent(address)+suffix)
image = idcon_render._render() image = idcon_render._render()