Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
SHA1HashAlgorithm.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* SHA1HashAlgorithm.h (C) 2000-2023 */
9/* */
10/* Calculates the SHA-1 hashing function. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_SHA1HASHALGORITHM_H
13#define ARCANE_UTILS_SHA1HASHALGORITHM_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/IHashAlgorithm.h"
18#include "arcane/utils/String.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Arcane::SHA1Algorithm
24{
25class SHA1;
26}
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
37class ARCANE_UTILS_EXPORT SHA1HashAlgorithm
38: public IHashAlgorithm
39{
40 public:
41
42 void computeHash(Span<const std::byte> input, HashAlgorithmValue& value) override;
43 void computeHash(ByteConstArrayView input, ByteArray& output) override;
44 void computeHash64(Span<const Byte> input, ByteArray& output) override;
45 void computeHash64(Span<const std::byte> input, ByteArray& output) override;
46 String name() const override { return "SHA1"; }
47 Int32 hashSize() const override { return 20; }
48 Ref<IHashAlgorithmContext> createContext() override;
49 bool hasCreateContext() const override { return true; }
50
51 private:
52
53 void _computeHash64(Span<const std::byte> input, ByteArray& output);
54 void _computeHash(Span<const std::byte> input, HashAlgorithmValue& value);
55};
56
57/*---------------------------------------------------------------------------*/
58/*---------------------------------------------------------------------------*/
59
60} // namespace Arcane
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65#endif
Hash algorithm return value.
Interface of a hashing algorithm.
Reference to an instance.
Implementation of the SHA-1 algorithm.
Int32 hashSize() const override
Size (in bytes) of the hash key.
void computeHash64(Span< const Byte > input, ByteArray &output) override
Calculates the hash value for the array input.
bool hasCreateContext() const override
Indicates if the implementation supports incremental hashing.
String name() const override
Name of the algorithm.
void computeHash(Span< const std::byte > input, HashAlgorithmValue &value) override
Calculates the hash value for the array input.
View of an array of elements of type T.
Definition Span.h:635
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< Byte > ByteArray
Dynamic one-dimensional array of characters.
Definition UtilsTypes.h:121
ConstArrayView< Byte > ByteConstArrayView
C equivalent of a 1D array of characters.
Definition UtilsTypes.h:476
std::int32_t Int32
Signed integer type of 32 bits.