"
COPYRIGHT (c) 1999 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
Stream subclass:#HashStream
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'System-Crypt-Streams'
!
!HashStream class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 1999 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
!
documentation
"
Abstract class. Subclasses generate hash values used as checksums
or for generating cryptographic signatures.
[author:]
Stefan Vogel
[see also:]
SHA1Stream MD5Stream
"
! !
!HashStream class methodsFor:'instance creation'!
hashValueOfFile:aFilename
|hashStream inStream|
hashStream := self new.
inStream := aFilename asFilename readStream binary.
inStream copyToEndInto:hashStream.
inStream close.
^ hashStream hashValue
"
MD5Stream hashValueOfFile:'Makefile'
"
!
new
"have to re-allow new - it was disabled in Stream"
^ self basicNew initialize
!
random
"create a random number geneartor using myself"
^ HashRandom with:self
"
SHA1Stream random next
"
"Modified: / 12.11.1999 / 17:21:17 / stefan"
! !
!HashStream methodsFor:'accessing'!
contents
"return the entire contents of the stream
- this is our hashValue."
^ self hashValue
"Created: / 17.3.1999 / 15:10:03 / stefan"
! !
!HashStream methodsFor:'not implemented'!
next
^ self shouldNotImplement
"Created: / 17.3.1999 / 15:11:03 / stefan"
! !
!HashStream methodsFor:'queries'!
blockSize
"the class knows about the basic block size"
^ self class blockSize
"Created: / 18.3.1999 / 10:17:02 / stefan"
!
hashSize
"the class knows about the basic hash size"
^ self class hashSize
"Created: / 18.3.1999 / 10:17:12 / stefan"
"Modified: / 15.10.1999 / 11:53:20 / stefan"
!
isReadable
"return true, if reading is supported by the recevier.
Always return false here"
^ false
"Modified: / 17.3.1999 / 15:06:09 / stefan"
!
isWritable
"return true, if writing is supported by the recevier.
Always return true here"
^ true
"Created: / 17.3.1999 / 15:05:49 / stefan"
! !
!HashStream methodsFor:'testing'!
atEnd
"return true if the end of the stream has been reached;
this is never reached"
^ false
"Created: / 17.3.1999 / 15:08:55 / stefan"
! !
!HashStream methodsFor:'writing'!
nextPutAll:aCollection
"Hash streams handle Strings and ByteArrays in nextPut:"
aCollection class isBytes ifTrue:[
self nextPut:aCollection.
] ifFalse:[
super nextPutAll:aCollection
].
"Created: / 14.10.1999 / 11:22:50 / stefan"
! !
!HashStream class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libbasic/HashStream.st,v 1.1 2002-11-18 12:41:58 cg Exp $'
! !