~ubuntu-branches/debian/sid/pyro/sid

« back to all changes in this revision

Viewing changes to examples/distributed-computing/tasks/md5crack.py

  • Committer: Bazaar Package Importer
  • Author(s): Bernd Zeimetz, Sandro Tosi, Bernd Zeimetz
  • Date: 2009-05-25 14:26:23 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090525142623-31cqgb2pdff6c1az
Tags: 3.9.1-1
[ Sandro Tosi ]
* debian/control
  - switch Vcs-Browser field to viewsvn

[ Bernd Zeimetz ]
* New upstream release.
* debian/patches/usr-bin-env-location.dpatch:
  - Dropping patch, applied usptream. 
* debian/control, debian/rules:
  - Dropping dpatch build-dep and include, not needed anymore. 
* Switching to python-support and dh 7.
* Bumping Standards-Version to 3.8.1. 
* Dropping maintainer scripts, dh creates them properly. 
* Adding missing ${misc:Depends}. 
* Fix several file permissions in the examples package.
* Add symlink to the actual docu in pyro-examples. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import tasks.task
2
2
 
3
 
import array
4
 
import md5
5
 
import time
 
3
import array, time
 
4
try:
 
5
        import hashlib
 
6
        md5=hashlib.md5
 
7
except ImportError:
 
8
        import md5
 
9
        md5=md5.md5
6
10
 
7
11
# Determine how fast your cpu is (est.)
8
12
# this is used to create a reasonable progress update rate.
10
14
print "(benchmarking...)"
11
15
CPU_SPEED=0
12
16
while time.time()-start < 1:
13
 
    void=md5.new("benchmark").digest()
 
17
    void=md5("benchmark").digest()
14
18
    CPU_SPEED+=1
15
19
CPU_SPEED /= 2
16
20
 
26
30
    def __init__(self, sourceText):
27
31
        tasks.task.PartitionableTask.__init__(self,"md5 guesser")
28
32
        self.source=sourceText                      # we will guess this
29
 
        self.md5hash=md5.new(self.source).digest()   # we will crack this
 
33
        self.md5hash=md5(self.source).digest()   # we will crack this
30
34
        self.result=None
31
35
    def split(self, numPiecesHint):
32
36
        pieces=numPiecesHint*3 # number of pieces
87
91
            while not self.result and not self.abort:
88
92
                for i in range(CPU_SPEED):
89
93
                    s = strings.next()
90
 
                    if md5.new(s).digest() == self.md5hash:
 
94
                    if md5(s).digest() == self.md5hash:
91
95
                        self.result=s # FOUND IT!!
92
96
                        return
93
97
                counter+=CPU_SPEED