1 //==- raw_sha1_ostream.h - raw_ostream that compute SHA1 --*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the raw_sha1_ostream class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_RAW_SHA1_OSTREAM_H
15 #define LLVM_SUPPORT_RAW_SHA1_OSTREAM_H
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/Support/SHA1.h"
19 #include "llvm/Support/raw_ostream.h"
23 /// A raw_ostream that hash the content using the sha1 algorithm.
24 class raw_sha1_ostream : public raw_ostream {
27 /// See raw_ostream::write_impl.
28 void write_impl(const char *Ptr, size_t Size) override {
29 State.update(ArrayRef<uint8_t>((const uint8_t *)Ptr, Size));
33 /// Return the current SHA1 hash for the content of the stream
36 return State.result();
39 /// Reset the internal state to start over from scratch.
40 void resetHash() { State.init(); }
42 uint64_t current_pos() const override { return 0; }
45 } // end llvm namespace