HashStream.st
changeset 7014 c443479ee603
parent 6864 0d5bd7218853
child 7015 862174119468
equal deleted inserted replaced
7013:993d318775b7 7014:c443479ee603
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
       
    13 
       
    14 "{ Package: 'stx:libbasic' }"
       
    15 
    13 Stream subclass:#HashStream
    16 Stream subclass:#HashStream
    14         instanceVariableNames:''
    17 	instanceVariableNames:''
    15         classVariableNames:''
    18 	classVariableNames:''
    16         poolDictionaries:''
    19 	poolDictionaries:''
    17         category:'System-Crypt-Streams'
    20 	category:'System-Crypt-Streams'
    18 !
    21 !
    19 
    22 
    20 !HashStream class methodsFor:'documentation'!
    23 !HashStream class methodsFor:'documentation'!
    21 
    24 
    22 copyright
    25 copyright
    47 "
    50 "
    48 ! !
    51 ! !
    49 
    52 
    50 !HashStream class methodsFor:'instance creation'!
    53 !HashStream class methodsFor:'instance creation'!
    51 
    54 
       
    55 hashValueOf:aStringOrByteArry
       
    56     ^ self hashValueOfStream:(aStringOrByteArry readStream)
       
    57 
       
    58     "
       
    59      MD5Stream hashValueOf:'BlaBlaBla'
       
    60     "
       
    61 !
       
    62 
    52 hashValueOfFile:aFilename
    63 hashValueOfFile:aFilename
    53     |hashStream inStream|
    64     ^ self hashValueOfStream:(aFilename asFilename readStream)
       
    65 
       
    66     "
       
    67      MD5Stream hashValueOfFile:'Makefile'
       
    68     "
       
    69 !
       
    70 
       
    71 hashValueOfStream:inStream
       
    72     |hashStream|
    54 
    73 
    55     hashStream := self new.
    74     hashStream := self new.
    56     inStream := aFilename asFilename readStream binary.
    75     inStream binary.
    57     inStream copyToEndInto:hashStream.
    76     inStream copyToEndInto:hashStream.
    58     inStream close.
    77     inStream close.
    59         
    78         
    60     ^ hashStream hashValue
    79     ^ hashStream hashValue
    61 
    80 
    62     "
    81     "
    63      MD5Stream hashValueOfFile:'Makefile'
    82      MD5Stream hashValueOfStream:('Makefile' asFilename readStream)
       
    83      MD5Stream hashValueOfStream:('BlaBla' readStream)
    64     "
    84     "
    65 !
    85 !
    66 
    86 
    67 new
    87 new
    68     "have to re-allow new - it was disabled in Stream"
    88     "have to re-allow new - it was disabled in Stream"
   165 ! !
   185 ! !
   166 
   186 
   167 !HashStream class methodsFor:'documentation'!
   187 !HashStream class methodsFor:'documentation'!
   168 
   188 
   169 version
   189 version
   170     ^ '$Header: /cvs/stx/stx/libbasic/HashStream.st,v 1.1 2002-11-18 12:41:58 cg Exp $'
   190     ^ '$Header: /cvs/stx/stx/libbasic/HashStream.st,v 1.2 2003-02-07 11:28:51 penk Exp $'
   171 ! !
   191 ! !