--- a/SHA1Stream.st Mon Feb 08 06:59:19 2016 +0100
+++ b/SHA1Stream.st Thu Feb 11 16:21:50 2016 +0000
@@ -11,6 +11,8 @@
"
"{ Package: 'stx:libbasic' }"
+"{ NameSpace: Smalltalk }"
+
HashStream subclass:#SHA1Stream
instanceVariableNames:'hashContext'
classVariableNames:'HashSize ContextSize'
@@ -340,7 +342,7 @@
"
Test Vectors (from FIPS PUB 180-1); results are:
- [exBegin]
+ [exBegin]
|hashStream|
hashStream := SHA1Stream new.
@@ -348,16 +350,23 @@
hashStream hashValue printOn:Transcript base:16. Transcript cr.
hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq'.
hashStream hashValue printOn:Transcript base:16. Transcript cr.
- [exEnd]
+ [exEnd]
+
+ [exBegin]
+ |hashValue|
- [exBegin]
+ hashValue := SHA1Stream hashValueOf:'hello world'.
+ self assert:(hashValue hexPrintString = '2AAE6C35C94FCFB415DBE95F408B9CE91EE846ED')
+ [exEnd]
+
+ [exBegin]
|hashValue|
hashValue := SHA1Stream hashValueOf:'abc'.
hashValue printOn:Transcript base:16. Transcript cr.
- [exEnd]
+ [exEnd]
- [exBegin]
+ [exBegin]
|hashStream|
hashStream := SHA1Stream new.
@@ -366,47 +375,47 @@
hashStream nextPut:'dbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq' asByteArray.
hashStream hashValue printOn:Transcript base:16. Transcript cr.
- [exEnd]
+ [exEnd]
- [exBegin]
+ [exBegin]
|hashStream|
hashStream := SHA1Stream new.
1000000 timesRepeat:[ hashStream nextPut:$a ].
hashStream hashValue printOn:Transcript base:16. Transcript cr.
- [exEnd]
+ [exEnd]
- [exBegin]
+ [exBegin]
|hashStream|
hashStream := SHA1Stream new.
hashStream nextPut:'a'.
hashStream hashValue printOn:Transcript base:16. Transcript cr.
- [exEnd]
+ [exEnd]
- [exBegin]
+ [exBegin]
|hashStream|
hashStream := SHA1Stream new.
hashStream nextPut:$a.
hashStream hashValue printOn:Transcript base:16. Transcript cr.
- [exEnd]
+ [exEnd]
timing throughput:
- [exBegin]
+ [exBegin]
|hashStream n t|
hashStream := SHA1Stream new.
n := 1000000.
t := Time millisecondsToRun:[
- n timesRepeat:[
- hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'.
- ].
- ].
+ n timesRepeat:[
+ hashStream nextPutAll:'12345678901234567890123456789012345678901234567890'.
+ ].
+ ].
t := (t / 1000) asFloat.
Transcript show:t; show:' seconds for '; show:(50*n/1024) asFloat; showCR:' Kb'.
Transcript show:(n*50/1024 / t); showCR:' Kb/s'
- [exEnd]
+ [exEnd]
"
!