I need to store a Digest::SHA512 object to a file in binary format.
That seemed trivial, but whatever I try just write it as an hexadecimal string.
I was expecting the following code to work:
bindigest=digest.update(chall)
File.open('sha1.bin', 'wb') {|file| file.write(bindigest) }
but it does not: it convert to plain text.
A similar question seems unanswered:
Can I serialize a ruby Digest::SHA1 instance object?
Using unpack tools require translating a bigint into a binary string, which again is not trivial... Any suggestion?
Thank you in advance!