I'm using tweetnacl to generate sha512 hashes of strings and file. For strings it works quite well but i have no idea how to do it with files.
The signature of the function ist
extern "C" int crypto_hash(u8 *out, const u8 *m, u64 n);
where u8 is of type unsigned char and u64 is of unsigend long long. For string a can use it like that
string s("Hello");
unsigned char h[64];
crypto_hash(h, (unsigned char *)s.c_str(), s.size());
This works great for a string and small files but if i want to create a hash for a big file, it is not viable and uses to much memory. I searching for a solution to read the file byte by byte and pass it as unsigend char pointer to that function. Has anyone a idea how to achieve that?
P.S Sorry for the poor English. p.s.s I use tweetnacl because of the small size and i need only the hashing function.