Closed yaghmr closed 10 years ago
In this case, the hash is generated from the content of your file, so it makes sense that it consumes the Source object. The file has to be read to build a hash.
You have two other options:
Tap
instead of directly building the hash. This allows the digest to be constructed passively as some other piece of code reads your source. Like this:val source = Algo.crc32.tap( Source.fromFile("data.csv") )
source.getLines.foreach( line => {
// Application logic to process each line
println(line)
})
println( "Hash: " + source.hash )
As a follow up, I added a section to the Readme about this:
https://github.com/Nycto/Hasher/commit/76447dd93585a229ca2be797301d08fd29159bd8
How I can do something like:
without empty my source iterator?. What's the correct way to calculate a Source's hash?