libxcks
0.1.0.1
Main Page
Related Pages
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
z
~
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
w
x
z
~
Variables
a
b
c
d
f
h
i
l
m
n
p
r
s
t
u
v
w
x
Typedefs
Enumerations
Files
File List
File Members
All
c
f
g
h
k
l
m
o
r
s
w
x
Macros
c
f
g
h
k
l
m
o
r
s
w
x
•
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Pages
checksumex.cpp
Go to the documentation of this file.
1
/*
2
* libxcks
3
* Copyright (C) 2022 Julien Couot
4
*
5
* This program is free software: you can redistribute it and/or modify it
6
* under the terms of the GNU Lesser General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or (at your
8
* option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13
* License for more details.
14
*
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17
*/
18
24
//---------------------------------------------------------------------------
25
#include <iomanip>
26
#include <sstream>
27
// #include <string> // included in "libxks/checksum.hpp" (included in "checksumex.hpp")
28
29
#include "
checksumex.hpp
"
30
//---------------------------------------------------------------------------
31
33
using namespace
std;
34
//---------------------------------------------------------------------------
35
36
37
namespace
libxcks
38
{
39
/*
40
* Returns the hash value as a string.
41
*/
42
string
ChecksumEx::toString(
const
bool
hexInUpperCase)
const
43
{
44
const
size_t
sumSize = getSize();
45
uint8_t* b =
new
uint8_t[sumSize];
46
47
// Puts the hash value in the buffer.
48
getValue(b);
49
50
// Puts the hash in a string
51
ostringstream ss;
52
if
(hexInUpperCase)
53
{
54
for
(
size_t
i = 0; i < sumSize; i++)
55
ss << uppercase << hex << setfill(
'0'
) << setw(2) <<
static_cast<
uint_fast16_t
>
(b[i]);
56
}
57
else
58
{
59
for
(
size_t
i = 0; i < sumSize; i++)
60
ss << hex << setfill(
'0'
) << setw(2) <<
static_cast<
uint_fast16_t
>
(b[i]);
61
}
62
63
delete
[] b;
64
return
ss.str();
65
}
66
//---------------------------------------------------------------------------
67
}
// namespace libxcks
68
//---------------------------------------------------------------------------
checksumex.hpp
Add some utilities to Checksum class.
src
algos
checksumex.cpp
Generated by
1.9.1