Usage is very straightforward:
julia> using SHA
julia> sha256("test")
"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
Each exported function (at the time of this writing, only SHA-1, SHA-2 224, 256, 384 and 512 functions are implemented) takes in either an Array{UInt8}
, a ByteString
or an IO
object. This makes it trivial to checksum a file:
shell> cat /tmp/test.txt
test
julia> using SHA
julia> open("/tmp/test.txt") do f
sha256(f)
end
"9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
Note the lack of a newline at the end of /tmp/text.txt
. Julia automatically inserts a newline before the julia>
prompt.