CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
hash_algorithm.h
1
2#ifndef _aspose_cryptography_hash_algorithm_h_
3#define _aspose_cryptography_hash_algorithm_h_
4
5#include "i_crypto_transform.h"
6#include "system/exceptions.h"
7#include "system/array.h"
8#include "system/io/stream.h"
9
10#ifdef ASPOSECPPLIB_BEING_BUILT
11#include <botan/hash.h>
12#else
13#include <cstdint>
14#endif
15
16
17namespace Botan {
19 ASPOSECPP_3RD_PARTY_CLASS(HashFunction);
20}
21
22
23namespace System{ namespace Security{ namespace Cryptography{
24
29class ASPOSECPP_SHARED_CLASS ABSTRACT HashAlgorithm : public ICryptoTransform
30{
31public:
33 virtual ASPOSECPP_SHARED_API ~HashAlgorithm();
34
38 ASPOSECPP_SHARED_API ArrayPtr<uint8_t> ComputeHash(const ArrayPtr<uint8_t>& buffer);
44 ASPOSECPP_SHARED_API ArrayPtr<uint8_t> ComputeHash(const ArrayPtr<uint8_t>& buffer, int offset, int count);
48 ASPOSECPP_SHARED_API ArrayPtr<uint8_t> ComputeHash(SharedPtr<IO::Stream> const& inputStream);
51 static ASPOSECPP_SHARED_API SharedPtr<HashAlgorithm> Create(const String& hashName);
52
54 ASPOSECPP_SHARED_API virtual void Initialize();
57 ASPOSECPP_SHARED_API virtual ArrayPtr<uint8_t> get_Hash();
60 ASPOSECPP_SHARED_API virtual int get_HashSize();
68 ASPOSECPP_SHARED_API int TransformBlock(ArrayPtr<uint8_t> inputBuffer, int inputOffset, int inputCount, ArrayPtr<uint8_t> outputBuffer, int outputOffset) override;
74 ASPOSECPP_SHARED_API ArrayPtr<uint8_t> TransformFinalBlock(ArrayPtr<uint8_t> inputBuffer, int inputOffset, int inputCount) override;
75
78 ASPOSECPP_SHARED_API int get_InputBlockSize() override;
81 ASPOSECPP_SHARED_API int get_OutputBlockSize() override;
82
83protected:
85 int HashSizeValue; // please don't replace it with m_hash_size_value because it corresponds to C# protected field.
86
88 ASPOSECPP_SHARED_API HashAlgorithm();
91 ASPOSECPP_SHARED_API HashAlgorithm( std::unique_ptr<Botan::HashFunction> hash_function );
92
97 ASPOSECPP_SHARED_API virtual void HashCore(System::ArrayPtr<uint8_t> array, int32_t ibStart, int32_t cbSize);
100 ASPOSECPP_SHARED_API virtual System::ArrayPtr<uint8_t> HashFinal();
101
102private:
104 std::unique_ptr<Botan::HashFunction> m_bt_hash_function;
106 std::vector<uint8_t> m_hash_value;
107};
108
109
110}}}// namespace System{ namespace Security{ namespace Cryptography{
111
112#endif // hash_algorithm_h
Base class for hashing algorithms. Objects of this class should only be allocated using System::MakeO...
Definition: hash_algorithm.h:30
int get_OutputBlockSize() override
Output block size.
ArrayPtr< uint8_t > ComputeHash(const ArrayPtr< uint8_t > &buffer)
Hashes buffer.
int get_InputBlockSize() override
Input block size.
virtual ArrayPtr< uint8_t > get_Hash()
Gets value of calculated hash code.
ArrayPtr< uint8_t > ComputeHash(SharedPtr< IO::Stream > const &inputStream)
Reads stream until end and calculates hash for the data read.
ArrayPtr< uint8_t > ComputeHash(const ArrayPtr< uint8_t > &buffer, int offset, int count)
Hashes buffer slice.
virtual void HashCore(System::ArrayPtr< uint8_t > array, int32_t ibStart, int32_t cbSize)
Passes data which is written into the object to the actual hash algorithm.
virtual int get_HashSize()
Gets size of calculated hash value in bytes.
ArrayPtr< uint8_t > TransformFinalBlock(ArrayPtr< uint8_t > inputBuffer, int inputOffset, int inputCount) override
Processes last block of data and calculates hash.
virtual System::ArrayPtr< uint8_t > HashFinal()
Finishes hash calculation.
HashAlgorithm(std::unique_ptr< Botan::HashFunction > hash_function)
Constructor.
virtual void Initialize()
Resets hasher into initial state.
int HashSizeValue
Size of computed hash code, in bits.
Definition: hash_algorithm.h:85
static SharedPtr< HashAlgorithm > Create(const String &hashName)
Creates hash algorithm based on name.
int TransformBlock(ArrayPtr< uint8_t > inputBuffer, int inputOffset, int inputCount, ArrayPtr< uint8_t > outputBuffer, int outputOffset) override
Processes block of data and copies data to output array.
Base class of cryptographic transformer. Objects of this class should only be allocated using System:...
Definition: i_crypto_transform.h:14
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Definition: db_command.h:9