HashResult BCryptHashImpl::Calculate(Aws::IStream& stream) { if(!IsValid()) { return HashResult(); } std::lock_guard<std::mutex> locker(m_algorithmMutex); auto startingPos = stream.tellg(); bool success = HashStream(stream); if(success) { stream.clear(); } stream.seekg(startingPos, stream.beg); if(!success) { return HashResult(); } return HashResult(ByteBuffer(m_hashBuffer, m_hashBufferLength)); }
int HashFile(const char * fname, unsigned char *hash, int bytes_to_read) { FILE *fp = fopen(fname, "rb"); if (fp != NULL) { int total_read = HashStream(fp, hash, bytes_to_read); fclose(fp); return total_read; } else { return -1; } }