Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
MD5HashAlgorithm.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 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/* MD5HashAlgorithm.cc (C) 2000-2023 */
9/* */
10/* Calcule la fonction de hashage MD5. */
11/*---------------------------------------------------------------------------*/
12
13#include "arcane/utils/StdHeader.h"
14#include "arcane/utils/MD5HashAlgorithm_Licensed.h"
15#include "arcane/utils/MD5HashAlgorithm.h"
16#include "arcane/utils/Array.h"
17#include "arcane/utils/Iostream.h"
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace
29{
30 void _computeHash64(Span<const std::byte> input, ByteArray& output)
31 {
32 unsigned char buf[16];
33 _md5_buffer((const char*)input.data(), input.size(), buf);
34
35 for (int i = 0; i < 16; ++i) {
36 output.add(buf[i]);
37 }
38 }
39} // namespace
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
43
44MD5HashAlgorithm::
45MD5HashAlgorithm()
46{
47}
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
51
54{
55 Span<const Byte> input64(input);
56 return _computeHash64(asBytes(input64), output);
57}
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
64{
65 Span<const std::byte> bytes(asBytes(input));
66 return _computeHash64(bytes, output);
67}
68
69/*---------------------------------------------------------------------------*/
70/*---------------------------------------------------------------------------*/
71
74{
75 return _computeHash64(input, output);
76}
77
78/*---------------------------------------------------------------------------*/
79/*---------------------------------------------------------------------------*/
80
81} // namespace Arcane
82
83/*---------------------------------------------------------------------------*/
84/*---------------------------------------------------------------------------*/
void computeHash(ByteConstArrayView input, ByteArray &output) override
Calcule la valeur du hash pour le tableau input.
void computeHash64(Span< const Byte > input, ByteArray &output) override
Calcule la valeur du hash pour le tableau input.
Classe de base des vecteurs 1D de données.
Vue constante d'un tableau de type T.
Vue d'un tableau d'éléments de type T.
Definition Span.h:510
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Array< Byte > ByteArray
Tableau dynamique à une dimension de caractères.
Definition UtilsTypes.h:321