Hi all.
Regarding the following discusion :
I have a similar issue with SHA1, in this way: I'm not able to obtain the same hash of my string comparing ti other site SHA1 calculator like:
My output is: 83b1df6a4ac9a2a4b5da922fa462e7ada1a58978
but the correct value should be: 6adfb183a4a2c94a2f92dab5ade762a47889a5a1
Below my code:
typedef struct {
uint8_t dataSource[SHA1MD5_VECTOR_LEN];
uint32_t dataLength;
} sha1Md5SourceData;
sha1Md5SourceData sha1md5LocalData;
uint32_t sha1md5LocalResult[5];
main
{
SHA1MD5HashSetMessage( "helloworld" );
SHA1MD5HashGenerate();
SHA1MD5GetHashResult( param2 );
printf("%s", param2);
}
void SHA1MD5HashGenerate( void )
{
SHAMD5Reset(SHAMD5_BASE);
SHAMD5ConfigSet(SHAMD5_BASE, SHAMD5_ALGO_SHA1);
SHAMD5DataProcess( SHAMD5_BASE, (uint32_t *)sha1md5LocalData.dataSource, sha1md5LocalData.dataLength, sha1md5LocalResult );
}
void SHA1MD5HashSetMessage( char *message )
{
memset( sha1md5LocalData.dataSource, 0, SHA1MD5_VECTOR_LEN );
memcpy( sha1md5LocalData.dataSource, message, len );
sha1md5LocalData.dataLength = (uint32_t)strlen( message);
}
Bool SHA1MD5GetHashResult( char *result )
{
sprintf( result, "%08x%08x%08x%08x%08x", sha1md5LocalResult[0],
sha1md5LocalResult[1],
sha1md5LocalResult[2],
sha1md5LocalResult[3],
sha1md5LocalResult[4] );
return (TRUE);
}