Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dhtnet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
dhtnet
Commits
e073c5ed
Commit
e073c5ed
authored
1 year ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
fileutils: remove sha3File, sha3sum
Change-Id: I7ffb6657cfdc3556d8292b2c087fd0aa732adc26
parent
4822fa09
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/fileutils.h
+0
-3
0 additions, 3 deletions
include/fileutils.h
src/fileutils.cpp
+0
-55
0 additions, 55 deletions
src/fileutils.cpp
with
0 additions
and
58 deletions
include/fileutils.h
+
0
−
3
View file @
e073c5ed
...
...
@@ -132,9 +132,6 @@ std::ofstream ofstream(const std::string& path, std::ios_base::openmode mode = s
int64_t
size
(
const
std
::
string
&
path
);
std
::
string
sha3File
(
const
std
::
string
&
path
);
std
::
string
sha3sum
(
const
std
::
vector
<
uint8_t
>&
buffer
);
/**
* Windows compatibility wrapper for checking read-only attribute
*/
...
...
This diff is collapsed.
Click to expand it.
src/fileutils.cpp
+
0
−
55
View file @
e073c5ed
...
...
@@ -56,8 +56,6 @@
#include
<wordexp.h>
#endif
#include
<nettle/sha3.h>
#include
<sstream>
#include
<fstream>
#include
<iostream>
...
...
@@ -786,59 +784,6 @@ size(const std::string& path)
return
size
;
}
std
::
string
sha3File
(
const
std
::
string
&
path
)
{
sha3_512_ctx
ctx
;
sha3_512_init
(
&
ctx
);
std
::
ifstream
file
;
try
{
if
(
!
fileutils
::
isFile
(
path
))
return
{};
openStream
(
file
,
path
,
std
::
ios
::
binary
|
std
::
ios
::
in
);
if
(
!
file
)
return
{};
std
::
vector
<
char
>
buffer
(
8192
,
0
);
while
(
!
file
.
eof
())
{
file
.
read
(
buffer
.
data
(),
buffer
.
size
());
std
::
streamsize
readSize
=
file
.
gcount
();
sha3_512_update
(
&
ctx
,
readSize
,
(
const
uint8_t
*
)
buffer
.
data
());
}
file
.
close
();
}
catch
(...)
{
return
{};
}
unsigned
char
digest
[
SHA3_512_DIGEST_SIZE
];
sha3_512_digest
(
&
ctx
,
SHA3_512_DIGEST_SIZE
,
digest
);
char
hash
[
SHA3_512_DIGEST_SIZE
*
2
];
for
(
int
i
=
0
;
i
<
SHA3_512_DIGEST_SIZE
;
++
i
)
pj_val_to_hex_digit
(
digest
[
i
],
&
hash
[
2
*
i
]);
return
{
hash
,
SHA3_512_DIGEST_SIZE
*
2
};
}
std
::
string
sha3sum
(
const
std
::
vector
<
uint8_t
>&
buffer
)
{
sha3_512_ctx
ctx
;
sha3_512_init
(
&
ctx
);
sha3_512_update
(
&
ctx
,
buffer
.
size
(),
(
const
uint8_t
*
)
buffer
.
data
());
unsigned
char
digest
[
SHA3_512_DIGEST_SIZE
];
sha3_512_digest
(
&
ctx
,
SHA3_512_DIGEST_SIZE
,
digest
);
char
hash
[
SHA3_512_DIGEST_SIZE
*
2
];
for
(
int
i
=
0
;
i
<
SHA3_512_DIGEST_SIZE
;
++
i
)
pj_val_to_hex_digit
(
digest
[
i
],
&
hash
[
2
*
i
]);
return
{
hash
,
SHA3_512_DIGEST_SIZE
*
2
};
}
int
accessFile
(
const
std
::
string
&
file
,
int
mode
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment