Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
libretro-chailove
Commits
a8ec7a99
Verified
Commit
a8ec7a99
authored
Apr 13, 2018
by
RobLoach
Browse files
md5: Update to use libretro-common
parent
d12b9c0d
Changes
2
Show whitespace changes
Inline
Side-by-side
Makefile.common
View file @
a8ec7a99
...
...
@@ -139,9 +139,9 @@ FLAGS += -I$(CORE_DIR)/vendor/Snippets
# STB
FLAGS
+=
-I
$(CORE_DIR)
/vendor/stb
#
Hash Library
FLAGS
+=
-I
$(CORE_DIR)
/vendor/
robloach-hash-library
SOURCES_C
XX
+=
$(CORE_DIR)
/vendor/
robloach-hash-library
/md5.c
pp
#
MD5
FLAGS
+=
-I
$(CORE_DIR)
/vendor/
libretro-common/include
SOURCES_C
+=
$(CORE_DIR)
/vendor/
libretro-common/utils
/md5.c
# ChaiScript
ifeq
($(HAVE_CHAISCRIPT),)
...
...
src/love/data.cpp
View file @
a8ec7a99
...
...
@@ -6,7 +6,7 @@
#include <sstream>
#include <iostream>
#include "zlib.h"
#include "md5.h"
#include "
utils/
md5.h"
namespace
love
{
...
...
@@ -94,8 +94,24 @@ std::string data::decompress(const std::string& str) {
std
::
string
data
::
hash
(
const
std
::
string
&
hashFunction
,
const
std
::
string
&
data
)
{
if
(
hashFunction
==
"md5"
)
{
MD5
md5
;
return
md5
(
data
);
const
char
*
input
=
data
.
c_str
();
unsigned
char
digest
[
16
];
// Calculate the MD5 hash using libretro-common.
MD5_CTX
context
;
MD5_Init
(
&
context
);
MD5_Update
(
&
context
,
input
,
strlen
(
input
));
MD5_Final
(
digest
,
&
context
);
// Construct the MD5 hash string.
char
md5string
[
33
];
for
(
int
i
=
0
;
i
<
16
;
++
i
)
{
snprintf
(
&
md5string
[
i
*
2
],
sizeof
(
&
md5string
[
i
*
2
]),
"%02x"
,
(
unsigned
int
)
digest
[
i
]);
}
// Output the hash.
std
::
string
output
(
md5string
);
return
output
;
}
std
::
cout
<<
"[ChaiLove] Error: Hash function not found: "
<<
hashFunction
<<
"."
<<
std
::
endl
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment