analitics

Pages

Friday, November 13, 2009

GTK - get display resolution

Sometime is need to get the display resolution.
This python code show how to do it:
>>> import gtk
>>> dgd=gtk.gdk.display_get_default()
>>> gsd=dgd.get_default_screen()
>>> height=gsd.get_height()
>>> width=gsd.get_width()
>>> print "height=",height,"width=",width
height= 1024 width= 1280

Quite simply ...

Wednesday, October 21, 2009

MD5 - password generator

Why do we need this script?
Internet is full of generating MD5.
The Internet has and dictionaries for decrypting md5.
So safe is our script.
You must use the code line:
p = md5.new ()

otherwise if you use:
pass = md5.new ()

you get the following error:
>>> pass = md5.new()
File "", line 1
pass = md5.new()
^
SyntaxError: invalid syntax

pass is a python keyword.
You'll need a different name for the variable.
And now to see the code:
import md5 
p = md5.new()
p.update("password")
p.hexdigest()
'5f4dcc3b5aa765d61d8327deb882cf99'

This is all you need.