Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

41 lines (35 sloc) 1.304 kB
TextMorph subclass: #Kember
instanceVariableNames: 'zeroes currHash found stopHash'
classVariableNames: ''
poolDictionaries: ''
category: 'Zaemis'!
!Kember methodsFor: 'as yet unclassified' stamp: 'TMB 6/19/2011 22:38'!
initialize
super initialize.
zeroes := '00000000000000000000000000000000'.
currHash := zeroes.
stopHash := '01', zeroes.
found := false.! !
!Kember methodsFor: 'as yet unclassified' stamp: 'TMB 6/19/2011 22:36'!
md5: aString
^ (MD5 new hashStream: (ReadStream on: aString)) hex.! !
!Kember methodsFor: 'as yet unclassified' stamp: 'TMB 6/19/2011 22:38'!
nextHash: aHashStr
| hexHash |
hexHash := ((ByteArray fromHexString: aHashStr) asInteger + 1) asByteArray hex.
hexHash size < 32
ifTrue: [^ (zeroes copyFrom: 1 to: 32 - hexHash size) , hexHash].
^ hexHash! !
!Kember methodsFor: 'as yet unclassified' stamp: 'TMB 6/19/2011 22:38'!
step
found | (currHash = stopHash)
ifFalse: [self contents: 'Testing ' , currHash.
found := self test: currHash.
found
ifTrue: [self contents: 'Found ' , currHash , '!!'].
currHash := self nextHash: currHash.
currHash = stopHash
ifTrue: [self contents: 'KI was not found.']].! !
!Kember methodsFor: 'as yet unclassified' stamp: 'TMB 6/19/2011 22:39'!
test: aHashStr
^ (self md5: aHashStr) = aHashStr.! !
Jump to Line
Something went wrong with that request. Please try again.