@@ -29,11 +29,39 @@ The latest version is ![maven-central]
2929API is pretty simple and quite limited :)
3030```
3131scala> import ky.korins.sha._
32+ import ky.korins.sha._
3233
3334scala> Sha2_256.hash("abc".getBytes())
3435val 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)
3536
3637scala>
3738```
3839
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+
3967[ maven-central ] : https://img.shields.io/maven-central/v/ky.korins/sha_2.13?style=flat-square
0 commit comments