File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
shared/src/main/scala/ky/korins/blake3 Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ All notable changes to this project will be documented in this file.
44
55## [ unreleased]
66- Switched to Scala.js-1.7.0.
7+ - ` hasher ` can be used now as ` OutputStream ` .
78
89## [ 2.8.0] - 2021-07-16
910- Introduced ` doneXor ` .
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ package ky.korins.blake3
1212import java .io .{InputStream , OutputStream }
1313import java .nio .ByteBuffer
1414
15- trait Hasher {
15+ trait Hasher extends OutputStream {
1616
1717 /**
1818 * Updates a hasher by provided bytes, returns the same hasher
@@ -224,4 +224,22 @@ trait Hasher {
224224 */
225225 def doneBase64Url (len : Int ): String =
226226 RFC4648 .base64_url(done(len))
227+
228+ /**
229+ * Update hash as [[OutputStream ]].
230+ */
231+ override def write (b : Int ): Unit =
232+ update(b.toByte)
233+
234+ /**
235+ * Update hash as [[OutputStream ]].
236+ */
237+ override def write (b : Array [Byte ]): Unit =
238+ update(b)
239+
240+ /**
241+ * Update hash as [[OutputStream ]].
242+ */
243+ override def write (b : Array [Byte ], off : Int , len : Int ): Unit =
244+ update(b, off, len)
227245}
You can’t perform that action at this time.
0 commit comments