@@ -29,11 +29,39 @@ The latest version is ![maven-central]
29
29
API is pretty simple and quite limited :)
30
30
```
31
31
scala> import ky.korins.sha._
32
+ import ky.korins.sha._
32
33
33
34
scala> Sha2_256.hash("abc".getBytes())
34
35
val res1: Array[Byte] = Array(-70, 120, 22, -65, -113, 1, -49, -22, 65, 65, 64, -34, 93, -82, 34, 35, -80, 3, 97, -93, -106, 23, 122, -100, -76, 16, -1, 97, -14, 0, 21, -83)
35
36
36
37
scala>
37
38
```
38
39
40
+ You may also create a new object from specified hash to ` update ` it, and at some
41
+ point ` finish ` it like this:
42
+ ```
43
+ scala> import ky.korins.sha._
44
+ import ky.korins.sha._
45
+
46
+ scala> val sha1 = new Sha1()
47
+ val sha1: ky.korins.sha.Sha1 = ky.korins.sha.Sha1@1224e1b6
48
+
49
+ scala> sha1.update("abc".getBytes(), 0, 2)
50
+
51
+ scala> sha1.update("abc".getBytes(), 2, 1)
52
+
53
+ scala> val hashed = new Array[Byte](20)
54
+ val hashed: Array[Byte] = Array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
55
+
56
+ scala> sha1.finish(hashed, 0)
57
+
58
+ scala> hashed
59
+ val res3: Array[Byte] = Array(-87, -103, 62, 54, 71, 6, -127, 106, -70, 62, 37, 113, 120, 80, -62, 108, -100, -48, -40, -99)
60
+
61
+ scala>
62
+ ```
63
+
64
+ All these objects aren't thread safe. After ` finish ` it should be treated as
65
+ broken.
66
+
39
67
[ maven-central ] : https://img.shields.io/maven-central/v/ky.korins/sha_2.13?style=flat-square
0 commit comments