* Added AES and AES-CTR modules. AES-CTR conforms to the same counter mode used with AES in *OpenSSL*. * All algorithms now work on Big-Endian architectures. * Now uses CMake for building rather than make files and Visual Studio projects. CMake will generate whatever system is required. * Input function parameters are now marked `const` * File names have been changed to have the prefix `CryptLib_` rather than `Lib`. * Various formatting changes to the files.
62 lines
1.9 KiB
C
62 lines
1.9 KiB
C
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// Md5String
|
|
//
|
|
// Outputs MD5 hash of a string specified on command line. Hash is output in hex
|
|
//
|
|
// This is free and unencumbered software released into the public domain - June 2013 waterjuice.org
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// IMPORTS
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include "CryptLib_Md5.h"
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// FUNCTIONS
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// main
|
|
//
|
|
// Program entry point
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
int
|
|
main
|
|
(
|
|
int ArgC,
|
|
char** ArgV
|
|
)
|
|
{
|
|
char* string;
|
|
Md5Context md5Context;
|
|
MD5_HASH md5Hash;
|
|
uint16_t i;
|
|
|
|
if( 2 != ArgC )
|
|
{
|
|
printf(
|
|
"Syntax\n"
|
|
" Md5String <String>\n" );
|
|
return 1;
|
|
}
|
|
|
|
string = ArgV[1];
|
|
|
|
Md5Initialise( &md5Context );
|
|
Md5Update( &md5Context, string, (uint32_t)strlen(string) );
|
|
Md5Finalise( &md5Context, &md5Hash );
|
|
|
|
for( i=0; i<sizeof(md5Hash); i++ )
|
|
{
|
|
printf( "0x%2.2x,", md5Hash.bytes[i] );
|
|
}
|
|
printf( "\n" );
|
|
|
|
return 0;
|
|
}
|