mirror of
https://github.com/libretro/RetroArch
synced 2025-02-10 21:40:22 +00:00
Move test over to samples
This commit is contained in:
parent
cad21249e0
commit
0ff69ec3df
@ -70,7 +70,8 @@ endif
|
||||
|
||||
DJB2_OBJS := $(CORE_DIR)/djb2.o
|
||||
|
||||
MD5_OBJS := $(CORE_DIR)/md5.o
|
||||
MD5_OBJS := $(CORE_DIR)/md5.o \
|
||||
$(PWD_DIR)/md5_test.o
|
||||
|
||||
SHA1_OBJS := $(CORE_DIR)/sha1.o \
|
||||
$(PWD_DIR)/sha1_main.o
|
||||
|
85
libretro-common/samples/utils/md5_test.c
Normal file
85
libretro-common/samples/utils/md5_test.c
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
|
||||
* MD5 Message-Digest Algorithm (RFC 1321).
|
||||
*
|
||||
* Homepage:
|
||||
* http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
|
||||
*
|
||||
* Author:
|
||||
* Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
|
||||
*
|
||||
* This software was written by Alexander Peslyak in 2001. No copyright is
|
||||
* claimed, and the software is hereby placed in the public domain.
|
||||
* In case this attempt to disclaim copyright and place the software in the
|
||||
* public domain is deemed null and void, then the software is
|
||||
* Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
|
||||
* general public under the following terms:
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted.
|
||||
*
|
||||
* There's ABSOLUTELY NO WARRANTY, express or implied.
|
||||
*
|
||||
* (This is a heavily cut-down "BSD license".)
|
||||
*
|
||||
* This differs from Colin Plumb's older public domain implementation in that
|
||||
* no exactly 32-bit integer data type is required (any 32-bit or wider
|
||||
* unsigned integer data type will do), there's no compile-time endianness
|
||||
* configuration, and the function prototypes match OpenSSL's. No code from
|
||||
* Colin Plumb's implementation has been reused; this comment merely compares
|
||||
* the properties of the two independent implementations.
|
||||
*
|
||||
* The primary goals of this implementation are portability and ease of use.
|
||||
* It is meant to be fast, but not as fast as possible. Some known
|
||||
* optimizations are not included to reduce source code size and avoid
|
||||
* compile-time configuration.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <rhash.h>
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
/* For each command line argument in turn:
|
||||
** filename -- prints message digest and name of file
|
||||
*/
|
||||
int i;
|
||||
MD5_CTX ctx;
|
||||
FILE* file;
|
||||
size_t numread;
|
||||
char buffer[16384];
|
||||
unsigned char result[16];
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
MD5_Init(&ctx);
|
||||
file = fopen(argv[i], "rb");
|
||||
|
||||
if (file)
|
||||
{
|
||||
do
|
||||
{
|
||||
numread = fread((void*)buffer, 1, sizeof(buffer), file);
|
||||
|
||||
if (numread)
|
||||
{
|
||||
MD5_Update(&ctx,(void*)buffer, numread);
|
||||
}
|
||||
}
|
||||
while (numread);
|
||||
|
||||
fclose(file);
|
||||
MD5_Final(result, &ctx);
|
||||
printf("%02x%02x%02x%02x%02x%02x%02x%02x"
|
||||
"%02x%02x%02x%02x%02x%02x%02x%02x %s\n",
|
||||
result[ 0 ], result[ 1 ], result[ 2 ], result[ 3 ],
|
||||
result[ 4 ], result[ 5 ], result[ 6 ], result[ 7 ],
|
||||
result[ 8 ], result[ 9 ], result[ 10 ], result[ 11 ],
|
||||
result[ 12 ], result[ 13 ], result[ 14 ], result[ 15 ],
|
||||
argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -293,54 +293,3 @@ void MD5_Final(unsigned char *result, MD5_CTX *ctx)
|
||||
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
}
|
||||
|
||||
#ifdef MD5_BUILD_UTILITY
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
/* For each command line argument in turn:
|
||||
** filename -- prints message digest and name of file
|
||||
*/
|
||||
int i;
|
||||
MD5_CTX ctx;
|
||||
FILE* file;
|
||||
size_t numread;
|
||||
char buffer[16384];
|
||||
unsigned char result[16];
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
MD5_Init(&ctx);
|
||||
file = fopen(argv[i], "rb");
|
||||
|
||||
if (file)
|
||||
{
|
||||
do
|
||||
{
|
||||
numread = fread((void*)buffer, 1, sizeof(buffer), file);
|
||||
|
||||
if (numread)
|
||||
{
|
||||
MD5_Update(&ctx,(void*)buffer, numread);
|
||||
}
|
||||
}
|
||||
while (numread);
|
||||
|
||||
fclose(file);
|
||||
MD5_Final(result, &ctx);
|
||||
printf("%02x%02x%02x%02x%02x%02x%02x%02x"
|
||||
"%02x%02x%02x%02x%02x%02x%02x%02x %s\n",
|
||||
result[ 0 ], result[ 1 ], result[ 2 ], result[ 3 ],
|
||||
result[ 4 ], result[ 5 ], result[ 6 ], result[ 7 ],
|
||||
result[ 8 ], result[ 9 ], result[ 10 ], result[ 11 ],
|
||||
result[ 12 ], result[ 13 ], result[ 14 ], result[ 15 ],
|
||||
argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user