File tree 2 files changed +20
-1
lines changed
shared/src/main/scala/ky/korins/blake3
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.
4
4
5
5
## [ unreleased]
6
6
- Switched to Scala.js-1.7.0.
7
+ - ` hasher ` can be used now as ` OutputStream ` .
7
8
8
9
## [ 2.8.0] - 2021-07-16
9
10
- Introduced ` doneXor ` .
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ package ky.korins.blake3
12
12
import java .io .{InputStream , OutputStream }
13
13
import java .nio .ByteBuffer
14
14
15
- trait Hasher {
15
+ trait Hasher extends OutputStream {
16
16
17
17
/**
18
18
* Updates a hasher by provided bytes, returns the same hasher
@@ -224,4 +224,22 @@ trait Hasher {
224
224
*/
225
225
def doneBase64Url (len : Int ): String =
226
226
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)
227
245
}
You can’t perform that action at this time.
0 commit comments