Files
WjCryptLib/projects/Sha1String/Sha1String.c
zebra f75d43bb19 Version 2.0.0
* 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.
2017-12-02 00:16:32 +11:00

62 lines
1.9 KiB
C

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sha1String
//
// Outputs SHA1 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_Sha1.h"
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// main
//
// Program entry point
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int
main
(
int ArgC,
char** ArgV
)
{
char* string;
Sha1Context sha1Context;
SHA1_HASH sha1Hash;
uint16_t i;
if( 2 != ArgC )
{
printf(
"Syntax\n"
" Sha1String <String>\n" );
return 1;
}
string = ArgV[1];
Sha1Initialise( &sha1Context );
Sha1Update( &sha1Context, string, (uint32_t)strlen(string) );
Sha1Finalise( &sha1Context, &sha1Hash );
for( i=0; i<sizeof(sha1Hash); i++ )
{
printf( "%2.2x", sha1Hash.bytes[i] );
}
printf( "\n" );
return 0;
}