So, I was wondering how can I use stream-stream to generate a file digest using java.security.MessageDigest?
I would like to do this using the size of the constant memory buffer (e.g. 4 KB). I think I understand how to start by reading the file, but I'm afraid to understand how:
1) call digest.update(buf)for every 4KB, which is effectively a side effect for the Java MessageDigest instance, which I suppose should happen inside the scalaz-stream framework.
2) finally, call digest.digest()to get back the computed digest from inside the scalaz-stream frame somehow?
I think I understand how to get started:
import scalaz.stream._
import java.security.MessageDigest
val f = "/a/b/myfile.bin"
val bufSize = 4096
val digest = MessageDigest.getInstance("SHA-256")
Process.constant(bufSize).toSource
.through(io.fileChunkR(f, bufSize))
!
, ? , , , ( ) - - - , .to(), ? , , scalaz. , .